假设我有一个容器,并且我想将这个容器放入另一个容器中,该容器也装满了其他东西。CSS 代码可能如下所示:
.parent-container {
width: 100%;
position: relative;
}
.child-container {
width: 600px;
position: absolute;
left: 25px;
bottom: 100px;
}
但是,.child-container
也包括绝对定位的元素,它们的位置相对于.parent-container
因为.child-container
没有position: relative
. 所以我的问题是,我怎样才能.child-container
相对于自身定位 的孩子,同时仍然保持正确定位.parent-container
?
PS 用 'd 包装.child-container
和position: absolute
制作div
应该.child-container
position: relative
可以解决问题,但我希望有更多...语义。