我有3个div,它们每一个都具有"position: absolute"属性。 第一个是头部,它可以正常工作。头部具有固定的高度,第二个div "content" 也可以正常工作。第三个div是"footer"。当"content"的高度大于浏览器窗口时,"content"的高度会改变,此时"footer"会覆盖在"content"上方。我希望"footer"始终在"content"下面,不管"content"的高度如何变化。我的头部高度为300px,content具有"margin-top: 300px"属性。我不能对footer使用相同的方法,因为content的高度并不固定。我不想设置一个具有"position: absolute"属性的div,然后把这3个div放在里面。
div#header{
width: 960px;
height: 200px;
left: 50%;
margin-left: -480px;
position: absolute;
}
div#content{
width: 960px;
border: 1px solid black;
left: 50%;
margin-left: -480px;
position: absolute;
margin-top: 200px;
}
div#footer{
width: 960px;
height: 30px;
left: 50%;
margin-left: -480px;
position: absolute;
bottom: 10px; /*with this i've div fixed to the bottom of web-browsers' window */
clear: both;
}