且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在相对定位div中包含绝对定位div?

更新时间:2021-12-09 02:29:23

如果相对放置的容器内的唯一元素的位置是绝对的,则必须在容器上指定高度。问题在于 position:absolue 从内容流中删除了元素,因此容器无法识别绝对定位的元素的高度。

If the only element inside your relatively positioned container is positioned absolute, you will have to specify a height on the container. The problem is that position:absolue removes the element from the content flow, so the container doesn't recognize the absolutely positioned element's height.