CSS: How to position two elements on top of each other, without specifying a height?

后端 未结 9 1308
走了就别回头了
走了就别回头了 2020-12-22 21:37

I have two DIVs that I need to position exactly on top of each other. However, when I do that, the formatting gets all screwed up because the containing DIV acts like there

9条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-22 22:10

    After much testing, I have verified that the original question is already right; missing just a couple of settings:

    • the container_row MUST have position: relative;
    • the children (...), MUST have position: absolute; left:0;
    • to make sure the children (...) align exactly over each other, the container_row should have additional styling:
      • height:x; line-height:x; vertical-align:middle;
      • text-align:center; could, also, help.

提交回复
热议问题