IE7 中列表项之间的 CSS 间隙
我无法消除 IE7 中列表项之间的间隙。
HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<link type="text/css" rel="stylesheet" href="base.css" />
</head>
<body>
<ul>
<li>
<div>row 1.1</div>
<div>row 1.2</div>
</li>
<li>
<div>row 2.1</div>
<div>row 2.2</div>
</li>
<li>
<div>row 3.1</div>
<div>row 3.2</div>
</li>
</ul>
</body>
</html>
CSS:
ul
{
padding: 0px;
margin: 0px;
}
li
{
list-style-type: none;
width: 100%;
margin: 0px;
padding: 0px;
border-bottom: 1px solid black;
border-left: 1px solid black;
border-right: 1px solid black;
}
li:first-child
{
border-top: 1px solid black;
}
li div
{
float: left;
width: 49.9%;
}
I'm unable to remove the gap between the list items in IE7.
HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<link type="text/css" rel="stylesheet" href="base.css" />
</head>
<body>
<ul>
<li>
<div>row 1.1</div>
<div>row 1.2</div>
</li>
<li>
<div>row 2.1</div>
<div>row 2.2</div>
</li>
<li>
<div>row 3.1</div>
<div>row 3.2</div>
</li>
</ul>
</body>
</html>
CSS:
ul
{
padding: 0px;
margin: 0px;
}
li
{
list-style-type: none;
width: 100%;
margin: 0px;
padding: 0px;
border-bottom: 1px solid black;
border-left: 1px solid black;
border-right: 1px solid black;
}
li:first-child
{
border-top: 1px solid black;
}
li div
{
float: left;
width: 49.9%;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
浮动
li
这将修复 IE7(这是 IE7 中的一个已知问题),但它也会让其他浏览器同时包含子浮动 - (他们没有这样做)
添加: ### 工作示例 ###
float the
li
toothis will fix IE7 (it's a known issue in IE7) but it will also get other browsers to contain the child floats at the same time - (which they weren't doing)
added: ### Working Example ###
IE 确实不是问题所在。
发生的情况是,您实际上在每个列表项之间有一个包含“\n\t\t\t”的文本节点,并且由于这些不是牢不可破的空格,IE 将它们解释为一个“”,这就是您所看到的。< br>
大多数情况下,IE 的问题是由于它遵循规范而引起的,而人们……不遵循规范。
IE is really not the problem here.
What happens is you actually have a text node containing "\n\t\t\t" between each of your list items, and since those aren't unbreakable spaces IE interprets them as one " ", which is what you see.
Most of the time problems with IE are caused by the fact that it follows the specification, and people ... don't.
还:
Also: