奇怪的 CSS/Nav 空白

发布于 2024-12-05 17:13:22 字数 2882 浏览 0 评论 0原文

大家好,堆栈溢出社区我们又见面了。我用 CSS 创建了这个两级导航栏,一切正常,但有一个小问题,有一个空白,我似乎无法摆脱

这是 Html

<ul id="nav-top">
        <li><a href="default.asp">Home</a></li>
        <li><a href="news.asp">News</a></li>
        <li><a href="contact.asp">Contact</a></li>
        <li><a href="about.asp">Join TGA</a></li>
    </ul>

    <img src="wp-content/themes/tga/pictures/topbanner.jpg" id="top-banner" />
    <div id="header">
    <ul id="nav-bottom">
            <li><a href="#">Percoidei</a>
        <ul>
            <li><a href="#">Remoras</a></li>
            <li><a href="#">Tilefishes</a></li>
            <li><a href="#">Bluefishes</a></li>
            <li><a href="#">Tigerfishes</a></li>
        </ul>
    </li>

    <li><a href="#">Anabantoidei</a>
        <ul>
            <li><a href="#">Climbing perches</a></li>
            <li><a href="#">Labyrinthfishes</a></li>
            <li><a href="#">Kissing gouramis</a></li>
            <li><a href="#">Pike-heads</a></li>
            <li><a href="#">Giant gouramis</a></li>
        </ul>
    </li>

这是 CSS 这

#nav-bottom{
    list-style-type:none;
    height: 34px;
    margin:0;
    padding:0;
    overflow:hidden;
    background-image: url(pictures/nav-graphic.png);
    line-height: 2;
}

#nav-bottom li:hover {
    list-style-type:none;
    height: 34px;
    margin:0;
    padding:0;
    overflow:hidden;
    line-height: 2;
    background-color: #494949;
    color: white;
}

#nav-bottom li{
    float:left;
}

#nav-bottom a{
    display:block;
    width:100px;
    text-decoration: none;
    color: black;
}



#nav-bottom li ul {
    position: absolute;
    width: 10em;
    left: -999em;
    list-style-type:none;
    background-color: #494949;
    color: white;
}


#nav-bottom li ul li a {
    color: white;
    width: 10em;
    border-bottom:1px solid white;
}

#nav-bottom li ul li a:hover {
    color: white;
    width: 10em;
    background-color: #2a2a2a;
    text-align: left;
    border-bottom:1px solid white;
}

#nav-bottom li:hover ul {
    left: auto;
}

是它的样子

看看下面的链接(抱歉没有代表点上传图片)

我做错了什么导致了空白?


好的,这是我正在谈论的空白区域 http://i52.tinypic.com/dcsg9j.png

我将其上传到jsfiddle(酷开发网站很喜欢它)并且它在那里工作得很好,你认为我的浏览器有问题吗(在 mac 上运行的 chrome 14.0.835.163)它也处理了空格火狐? http://jsfiddle.net/donvito101/ZWeVq/

Hello stack overflow community we meet again. I create this two leveled Navigation bar with CSS and i got everything to work but for one little issue, there a blank space that i can't seem to get rid of

Here is the Html

<ul id="nav-top">
        <li><a href="default.asp">Home</a></li>
        <li><a href="news.asp">News</a></li>
        <li><a href="contact.asp">Contact</a></li>
        <li><a href="about.asp">Join TGA</a></li>
    </ul>

    <img src="wp-content/themes/tga/pictures/topbanner.jpg" id="top-banner" />
    <div id="header">
    <ul id="nav-bottom">
            <li><a href="#">Percoidei</a>
        <ul>
            <li><a href="#">Remoras</a></li>
            <li><a href="#">Tilefishes</a></li>
            <li><a href="#">Bluefishes</a></li>
            <li><a href="#">Tigerfishes</a></li>
        </ul>
    </li>

    <li><a href="#">Anabantoidei</a>
        <ul>
            <li><a href="#">Climbing perches</a></li>
            <li><a href="#">Labyrinthfishes</a></li>
            <li><a href="#">Kissing gouramis</a></li>
            <li><a href="#">Pike-heads</a></li>
            <li><a href="#">Giant gouramis</a></li>
        </ul>
    </li>

And here is the CSS

#nav-bottom{
    list-style-type:none;
    height: 34px;
    margin:0;
    padding:0;
    overflow:hidden;
    background-image: url(pictures/nav-graphic.png);
    line-height: 2;
}

#nav-bottom li:hover {
    list-style-type:none;
    height: 34px;
    margin:0;
    padding:0;
    overflow:hidden;
    line-height: 2;
    background-color: #494949;
    color: white;
}

#nav-bottom li{
    float:left;
}

#nav-bottom a{
    display:block;
    width:100px;
    text-decoration: none;
    color: black;
}



#nav-bottom li ul {
    position: absolute;
    width: 10em;
    left: -999em;
    list-style-type:none;
    background-color: #494949;
    color: white;
}


#nav-bottom li ul li a {
    color: white;
    width: 10em;
    border-bottom:1px solid white;
}

#nav-bottom li ul li a:hover {
    color: white;
    width: 10em;
    background-color: #2a2a2a;
    text-align: left;
    border-bottom:1px solid white;
}

#nav-bottom li:hover ul {
    left: auto;
}

Here is what it looks like

look at link bellow (sorry don't have the rep points to upload the picture)

What am i doing wrong that causing that blank space?


Ok here is the blank space i'm talking about
http://i52.tinypic.com/dcsg9j.png

And I uploaded it to jsfiddle (cool dev site love it) and it works fine in there, do you think is a problem with my browser (chrome 14.0.835.163 running on mac) it also does the blank space in firefox?
http://jsfiddle.net/donvito101/ZWeVq/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

彩扇题诗 2024-12-12 17:13:22

我猜你的意思是缩进子菜单的空格?
在这种情况下,这可能是因为您正在子菜单中开始一个新菜单,该菜单始终是缩进的。为 #nav-bottom ul 添加一些 px 负填充(或边距?),你应该会很好!例如

#nav-bottom ul { padding-left: -15px; }

I guess you mean that blank space that indents the submenu ?
In this case it's propably because you are starting a new in the submenu, which is always indented. Put a few px negative padding (or margin?) for #nav-bottom ul and you should be good! e.g.

#nav-bottom ul { padding-left: -15px; }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文