小编mee*_*ect的帖子

css div之间的垂直差距

我知道这是一个常见问题,但我似乎无法找到有效的解决方案.我有这样的设置:

 <div id="wrapper">
  <div class="content-area-top"></div>
  <div class="content-area">
   <h1>Title</h1>
   some other text
  </div>
 </div>

.content-area-top {
  height: 12px;
  width: 581px;
  background-image: url(images/content-top.jpg);
 }

.content-area {
margin-left: 10px;
margin-right: 10px;
    background-color: #e9ecfd;
 }
Run Code Online (Sandbox Code Playgroud)

问题是.content-area-top和.content-area之间存在差距..content-area-top div的大小适合包含一个背景图像,它可以提供我想要的圆角.

我知道这个问题来自H1标签有(浏览器默认)上边距设置(.67em),但我不愿意将其边距设置为0,我不明白为什么其保证金适用于'外'它包含div.

我在Mac上使用chrome,但firefox也有同样的问题.这可能是一些众所周知的修复,但我无法找到特定于我的案例的解决方案.

html css

15
推荐指数
1
解决办法
6万
查看次数

标签 统计

css ×1

html ×1