如何摆脱DIV之间的这一片白色?

时间:2010-05-29 20:07:41

标签: css html positioning

我目前无法摆脱一丝白色......

以下是一个示例页面:http://m.stackoverflow.quickmediasolutions.com/view_question.php?id=97969&site=serverfault

正如您所看到的,答案在“按钮”的顶部和内容之间插入了一小段白色。

以下是一些相关代码:

<!-- this is the top of the 'button' -->
<div class='top'></div>

<!-- right here is where the space is -->
<div class='content'></div>

.top {
    height: 5px;
}
.content {
    display: block;
    padding-left: 10px;
}

修改:此问题已修复,我很快就会接受以下答案。

2 个答案:

答案 0 :(得分:4)

这看起来像<p>元素具有的原始边距:

.question p { margin: 0 }

这里有一个相关提示,它使用CSS-Reset,它消除了大多数这些奇怪的问题和跨浏览器兼容性问题。

答案 1 :(得分:0)

你知道吗,你会惊讶地发现空白打破布局的频率。我找到了困难的方法。

只是为了$ hits和giggles一起写出来看看会发生什么:

<div class='top'></div><div class='content'></div>

当然我会确保在你的CSS中为两个div定义margin:0px;

相关问题