我有以下内容:
<div id="aboutus">
<div id="header"></div>
<div id="headerbar"><p>ABOUT US</p></div>
<div id="contentarea">
<p>CONTENT ABOUT US</div>
<div id="clear"></div></div>
<div id="contact">
<div id="header"></div>
<div id="headerbar"><p>CONTACT US</p></div></div>
<div id="contentarea">CONTENT CONTACT US</div>
<div id="clear"></div>
</div>
和:
#aboutus {
float:left;
width:100%;
height:100%;
}
#contact{
float:left;
width:100%;
height:100%;
}
#headerbar {
float:left;
width:25%;
height:100px;
text-align:right;
padding-right:5px;
}
#contentarea{
float:left;
width:70%;
height:100px;
}
#clear{
clear: both;
}
#header{
background:url(bg.png) no-repeat center center;
background-size:contain;
width:100%;
height:200px;
}
我对此完全陌生,所以我确定自己在做些愚蠢的事情。基本上它的两个2柱状图布局彼此重叠,aboutus div很好,但是contact div在about us div中显示。关于我在做什么错的任何建议吗?
最佳答案
如果您要在另一个div上指定两个div,可以使用display:block;
指定width:100%;
,如下所示
.div{
display: block;
width: 100%;
}
您不必使用浮点数。当然,有很多方法可以实现,这是实现此目的的方法之一。您可以在这里http://jsfiddle.net/qiqiabaziz/mrrQU/