您可以使用position: absolute
。
.container
{
height: 400px;
position: relative;
}
.adInfoBox1 {
padding: 5px 5px 5px 10px;
position: absolute;
bottom: 0px;
width: 457px;
background-color: green;
}
.adRegularList .categoryList {
bottom: 0;
height: 16px;
position: absolute;
}
可以在这里查看一个可运行的示例:http://jsfiddle.net/hxXJh/5/
我建议:
.adInfoBox1 {
padding: 5px 5px 5px 10px;
position: absolute;
bottom: 0; /* attaches the element to the bottom */
left: 0; /* attaches the element to the left-side */
right: 0; /* attaches the element to the right-side */
background-color : green;
}
.adInfoBox
的宽度设置为100%。可以通过删除或修改right
或left
声明来进行调整。我删除了float
,因为使用position: absolute;
会将元素从文档流中移除。
JS Fiddle演示。简单巧妙的解决方案。Div2将位于containerDiv底部。
<div id="containerDiv">
<div id="div1" style="heigth:90%;"></div>
<div id="div2">Content here...</div>
</div>
将adInfoBox1
的CSS更改为:
.adInfoBox1 {
float: left;
padding: 5px 5px 5px 10px;
position: absolute;
width: 457px;
background-color : green;
bottom: 0;
}