代码:
HTML:
<div id = "LeftDiv">
<p class = "hdr">ADVANCED SEARCH:</p>
<div class = "LeftItem">
<form>
<p style="margin:0;padding: 10px 0;">Weird Space above this</p>
<input type = "text" name = "search" />
<input type = "submit" value = "Go" />
</form>
<br />
</div>
<br />
...There are some more (like a vertical navigation bar,
which also has this gap between the header and the navigation bar)
CSS:
#LeftDiv
{
float: left;
width: 20%;
text-align: center;
color: #fff;
}
.LeftItem
{
background: #000 url("") no-repeat;
}
.hdr
{
text-transform: uppercase;
font-weight: bold;
background: url("header.png") no-repeat;
padding: 10px 0;
margin: 0;
}
奇怪的是,这种情况发生在Firefox,而不是在Chrome。另外,当使用Firefox进行缩放时,此空间会消失。
我不确定为什么发生这种情况。这是因为<p>
不在'LeftItem'div内吗?
如果您使hdr p成为div,会发生什么情况? –
为什么你只是不简单地删除p标签,看看会发生什么 – kechapito
同样的事情,我只是添加了p标签,为你们看清楚这个差距... –