我有一个使用position:absolute定位的div,我想把另一个div放在它下面。
这两个div宽度不同。
上面的div采用绝对定位并居中。 应该在底部的div具有100%的宽度。
如何实现?
谢谢!
div
float:right
示例:
div#p8015buttons {
position:absolute;
bottom:0.5em;
right:0.5em;
width:90px;
}
div.p8015 {
float:right;
margin:1px;
}
没有测试过,但应该可以。
HTML:
<div class="wrapper">
<div class="one">
Content
</div>
<div class="two">
More content
</div>
</div>
还有CSS:
.wrapper
{
position:absolute;
width: 500px;
height: 400px;/*whatever you want*/
}
.one,
.two
{
position:relative; /*or static*/
}
测试 HTML 标记
<div class="wrapper">
<div class="left-ontent>
</div>
<div class="right-ontent>
</div>
</div>
CSS
.wrapper{width:980px;margin:0 auto;position:absolute;}
.left-content{float:left;width:630px;}
.right-content{float:right;width:320px;}
试试这个,然后你可以将样式移动到你的CSS中
<div style="width:500px; margin: auto; height:200px; background-color:black;">
</div>
<div style="width:100%; height:200px; background-color:green;">
</div>
float: center;
这样的东西。http://www.w3schools.com/css/pr_class_float.asp - Kyle
div
,里面有两个静态定位的div
(它们会叠放在一起)。 - Dan