【发布时间】:2012-07-13 09:29:57
【问题描述】:
我现在有一个非常简单的布局:
<div class="spacer">
<h1>Finalizing Your Account </h1>
</div>
<div class="greycont60 greycont">
<div class="minispacer"><h5>Almost done! Just a few things left...</h5></div>
</div>
<div class="greycont40 greycont"></div>
<div style="clear:both;"></div>
这是 CSS:
.minispacer {
background: #d9d9d9;
height:30px;
width: 300px;
padding-left:10px;
}
.greycont60 {
width: 56%;
float: left;
}
.greycont40 {
width: 36%;
float: right;
}
.spacer {
height:56px;
background:url(../images/bg2.png) repeat;
padding:0 10px;
margin-top:20px;
margin-bottom:10px;
}
.spacer h1 {
font-size:22px;
padding-top:4px;
color:#727272;
}
.greycont {
background-color:#e8e8e8;
padding:15px;
margin-bottom:10px;
}
现在结果是这样的:
为什么他们的 MiniSpacer 条有这么大的空间?我尝试添加 1px 的顶部填充,但突然间栏做了一些疯狂的事情......
【问题讨论】:
-
JSFiddle 在这里会很有帮助。
标签: html css-float margin padding