【问题标题】:Where is the extra margin/padding coming from?额外的边距/填充来自哪里?
【发布时间】: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


【解决方案1】:

尝试添加边距:0px;到您的 h5 标记。 标题标签获得默认的顶部和底部边距。

谢谢, 阿迪亚

【讨论】:

    猜你喜欢
    • 2010-12-04
    • 1970-01-01
    • 1970-01-01
    • 2020-01-19
    • 1970-01-01
    • 2011-03-19
    • 2013-04-25
    • 2013-08-15
    • 2014-05-15
    相关资源
    最近更新 更多