简体   繁体   English

IE7中列表项之间的CSS差距

[英]CSS gap between list items in IE7

I'm unable to remove the gap between the list items in IE7. 我无法消除IE7中列表项之间的差距。

HTML: 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: 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%;
}

float the li too 也漂浮了li

li
{
    list-style-type: none;      
    width: 100%;
    float: left;    
    margin: 0px;
    padding: 0px;   
    border-bottom: 1px solid black;
    border-left: 1px solid black;
    border-right: 1px solid black;          
}

this 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) 这将修复IE7(这是IE7中的一个已知问题),但它也会让其他浏览器同时包含子浮动 - (他们没有这样做)

added: ### Working Example ### 补充说:### 工作实例 ###

IE is really not the problem here. IE在这里真的不是问题。
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. 实际上你在每个列表项之间有一个包含“\\ n \\ t \\ t \\ t \\ t”的文本节点,因为那些不是牢不可破的空格,IE将它们解释为一个“”,这就是你所看到的。
Most of the time problems with IE are caused by the fact that it follows the specification, and people ... don't. 大多数情况下IE的问题是由于它遵循规范,而人们......不这样做。

<!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>

Also: 也:

<!--[if lte IE 7]>
li {
...
margin-bottom: -3px;
...
}
<![endif]-->

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM