2

<li></li>当源中没有空格时,为什么以下标记会在 each 之后产生一个空格?如果我将它们全部放在一行上,则预览页面时空格会消失。但是为什么浏览器将我的标签读取为空格?

(您可以在第一张图片的左侧看到服务旁边的边框。该边框和服务之间是空间。它在图片 2 中不存在。)

在此处输入图像描述

<nav>
    <ul>
        <li><a href="#" class="active">HOME</a></li>
        <li><a href="#">SERVICES</a></li>
        <li><a href="#">PRODUCTS</a></li>
        <li><a href="#">ABOUT</a></li>
        <li><a href="#">CONTACT</a></li>
        <li><a href="#">LIKE US</a></li>
    </ul>
</nav>

这是删除所有选项卡的情况:

在此处输入图像描述

<nav>
    <ul>
        <li><a href="#" class="active">HOME</a></li><li><a href="#">SERVICES</a></li><li><a href="#">PRODUCTS</a></li><li><a href="#">ABOUT</a></li><li><a href="#">CONTACT</a></li><li><a href="#">LIKE US</a></li>
    </ul>
</nav>

编辑:

浏览器是 OSX Lion 上的 Safari 5.1.5。编辑是 Espresso。还尝试了TextMate。这是导航的 CSS。

nav {
    position: relative;
    width: 960px;
    padding: 0 30px;
    background: #281601; /* Old browsers */
    background: -moz-linear-gradient(left,  #3f2c16 0%, #281601 5%, #281601 95%, #3f2c16 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, right top, color-stop(0%,#3f2c16), color-stop(5%,#281601), color-stop(95%,#281601), color-stop(100%,#3f2c16)); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(left,  #3f2c16 0%,#281601 5%,#281601 95%,#3f2c16 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(left,  #3f2c16 0%,#281601 5%,#281601 95%,#3f2c16 100%); /* Opera 11.10+ */
    background: -ms-linear-gradient(left,  #3f2c16 0%,#281601 5%,#281601 95%,#3f2c16 100%); /* IE10+ */
    background: linear-gradient(left,  #3f2c16 0%,#281601 5%,#281601 95%,#3f2c16 100%); /* W3C */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3f2c16', endColorstr='#3f2c16',GradientType=1 ); /* IE6-9 */
    font-family: 'Crimson Text', serif;
    color: #fff;
}

nav:before {
    position: absolute;
    left: -12px;
    top: 0px;
    content: url('../img/nav-left.png');
}

nav:after {
    position: absolute;
    left: 960px;
    top: 0px;
    content: url('../img/nav-right.png');
}

nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

nav ul li {
    display: inline-block;
}

nav ul li a, nav ul li a:visited {
    display: block;
    color: #c7beb4;
    text-decoration: none;
    font-size: 95%;
    letter-spacing: 0.08em;
    padding: 12px 20px;
    border-right: 1px solid #3b2b18;
}

nav ul li:first-child a:before {
    content: url('../img/nav-icon-home.png');
    margin: 0px 8px 0 0;
}

nav ul li:first-child a:hover:before {
    content: url('../img/nav-icon-home-active.png');
}

nav ul li:last-child {
    float: right;
}

nav ul li:last-child a {
    border:none;
}

nav ul li:last-child a:before {
    content: url('../img/nav-icon-facebook.png');
    margin: 0px 8px 0 0;
}

nav ul li:last-child a:hover:before {
    content: url('../img/nav-icon-facebook-active.png');
}

nav ul li a:hover {
    background: #c7beb4;
    color: #281601;
    box-shadow: inset 0 0 15px rgba(40,22,1,0.5);
}
4

1 回答 1

0

将 li 的显示更改为 display:table-cell 而不是 display:inline-block。

于 2012-04-09T20:14:16.113 回答