我的css出现问题似乎没有被接受。我有3种不同类型的具有相同字符的样式。奇怪的是,当我应用<div class = "block halfleft">..</div>
时,它会显示正确的样式,但<div class = "twoblock halfleft">
似乎不起作用!是什么原因引起了这个?
CSS
#member {
padding: 0;
}
#member .block {
width: 960px;
margin-bottom: 40px;
padding-left:30px;
height: 475px;
float: left;
text-align: left;
}
#member .twoblock {
width: 960px;
margin-bottom: 0;
padding-left:75px;
padding-bottom: 75px;
height: 100%;
float: left;
text-align: left;
}
#member .threeblock {
width: 960px;
margin-bottom: 0;
padding-left:75px;
padding-bottom: 75px;
height: 500px;
background-color: #fff;
float: left;
text-align: left;
}
#member .block.halfleft, #member .twoblock.halfleft, #member .threeblock.halfleft{
width: 520px;
height: 240px;
float: left;
padding-top: 25px;
}
#member .block.halfright, #member .twoblock.halfright, #member .threeblock.halfright{
width: 350px;
height: 240px;
float: left;
padding-top: 55px;
}
PAGE
//WORKS://
<div class="block">
<div class="block halfleft">//text//</div>
<div class="block halfright">//text//</div>
</div>
//DOESNT WORK BUT WHAT I WANT TO MAKE WORKING://
<div class="twoblock">
<div class="twoblock halfleft">//text//</div>
<div class="twoblock halfright">//text//</div>
</div>
//WORKS://
<div class="twoblock">
<div class="block halfleft">//text//</div>
<div class="block halfright">//text//</div>
</div>
答案 0 :(得分:1)
你有一些填充问题! 75px正在加倍.twoblock&gt; .twoblock和其他几个案例。避免这种情况的简单方法是添加
box-sizing:border-box;
到你的所有定义,这意味着填充将包含在定义的宽度中,而不是添加到它。