我试图让一个 div (覆盖)漂浮在其他 3 个 div 之上。它切入了第一个(horsebanner)和第三个(页脚)div,并完全覆盖了第二个(中间背景)。我希望第二个 div 的大小随着浮动 div 的增加而自动增加,以便浮动 div 切入第三个 div 的数量始终保持不变。
这是html:
<body>
<div id="navigation">
</div>
<div id="main">
<div class="overlay">
</div>
<div class="horsebanner">
</div>
<div class="midbackground">
</div>
<div class="footer">
</div>
</div>
</body>
这里的CSS:
#main {
width: auto;
height: 650px;
background-color: #FF6;
margin-top: 0;
}
#main .horsebanner {
width: auto;
height: 150px;
background-color: #F90;
margin-top: 0;
}
#main .midbackground {
width: auto;
height: 450px;
background-color: #CCC;
margin-top: 0;
}
#main .footer {
width: auto;
height: 50px;
background-color: #333;
margin-top: 0;
}
#main .overlay {
width: 300px;
height: 100px;
margin-left:100px;
margin-right:100px;
background-color:#0F0;
position: absolute;
}
我是 html 世界的新手,可以使用一些建议。再次,尝试让中间背景 DIV 随着覆盖 DIV 变大而调整得更大。