【发布时间】:2011-05-07 02:08:44
【问题描述】:
我在 IE7 中有一个不寻常的 CSS 问题。这是我的html和css代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="ltr">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<style type="text/css">
.generic_panel {background-color:red; padding:15px; display:block; overflow:hidden;}
.generic_panel h4 {background-color:green; margin:0px; display:block; float:left;}
.generic_panel h2 {background-color:blue; margin:0px; display:block; clear:both; float:none;}
</style>
<!--[if lt IE 9]>
<script src="https://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<section id="content">
<section id="payment" class="generic_panel">
<h4><a href="http://mysite.com">Invoice # 000095</a></h4>
<h2>Remaining Invoice Amount: $17.5<br/>
<span>Original Amount: $17.50</span>
</h2>
</section>
</section>
</body>
</html>
在 IE7 中查看时,h4 和 h2 标记之间有空格。我一直在努力摆脱那个空白。我不明白为什么 .generic_panel h2 {margin:0px;} 和 .generic_panel h4 {margin:0px;} 属性没有摆脱那个空白。
更奇怪的是,如果我从
中删除padding:15px 或 display:block 或 overflow:hidden 中的任何一个
.generic_panel {background-color:red; padding:15px; display:block; overflow:hidden;}
然后它摆脱了 h4 和 h2 之间的空白。为什么我的.generic_panel 中的 css 属性会影响我的 h4 和 h2 标签之间的间距?
请帮助我了解 $@#%#$%$ 发生了什么......
【问题讨论】:
标签: css internet-explorer internet-explorer-7