我有 3 个 div,每个都有 position: absolute
。
首先是标题及其工作。
标题的高度不变,第二个 div“内容”也有效。
第三个 div 是“页脚”。
“内容”的高度可变,当“内容”高于网络浏览器窗口时,“页脚”处于“内容”状态。无论内容高度如何,我都想在“内容”下添加“页脚”。
我的标题是 300px 高度,内容有 margin-top: 300px
。我不能对页脚使用同样的方法,因为内容的高度不是固定的。
我不想用 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;
}
最佳答案
关于css - div 下的位置 : absolute, div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8531323/