假设我有一个容器,并且我想将这个容器放入另一个容器中,该容器也装满了其他东西。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可以解决问题,但我希望有更多...语义。
*请注意,每个位置都相对于其父位置。