<分区>
<分区>
我在容器 div 中有两个 div。它们使用绝对定位彼此相邻定位。它们的宽度总是相同的,容器 div 的宽度也总是相同的。这是好习惯吗?还是应该使用 float:left 和 float:right?
CSS 看起来像这样:
#container
{
margin:0 auto;
height:100%;
width:960px;
}
#left
{
position:absolute;
top:0px;
left:0px;
bottom:0px;
width:25%;
height:100%;
}
#right
{
position:absolute;
top:0px;
left:25%;
bottom:0px;
right:0px;
width:auto;
height:100%;
}
这是好的做法吗?如果我想使用相对定位,使用相对定位定位的元素不能重叠,不是吗?我的意思是,他们知道他们每个人在哪里,对吧?
谢谢:D
最佳答案
我会使用 float ,这样当内容填满时你就不必硬编码容器的高度
关于html - 在一个容器中有 2 个绝对定位的元素是好的做法吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16922382/