chrome和firefox中的css导航菜单问题

发布于 2024-11-30 12:47:15 字数 2408 浏览 0 评论 0原文

你好,我已经编写了 css 代码来显示菜单栏。遇到了很多问题,用谷歌搜索并找到了解决方案。但这个我找不到。
这是 chrome 输出,菜单框之间有间隙,但如果是 firefox,则完全没有问题。它的联系方式。我该如何解决这个问题?

CSS

#candymenu li {
    list-style-type: none;
    display: inline-block;
    width: 8.1em;
    float: center;
    text-align: center;
    font-family: "Lucida Grande", sans-serif;
    height: 3em;
}
#candymenu ul {
    width: 100%;
    margin:0 153px;

}   


#candymenu li a {
    display: inline-block;
    margin 150px;    
    padding: .5em .5em .5em .5em;
    text-decoration: none;
}

#candymenu li {
    list-style-type: none;
    display: inline-block;

    width: 8.1em;
    float: center;
    text-align: center;
    font-family: "Lucida Grande", sans-serif;
    height: 3em;
    border-right: 1px #818181 solid;
    -webkit-box-shadow: 1px 1px  #bbb;
    box-shadow: 1px 1px  1px #bbb;
}

#candymenu li a {
    display: inline-block;
    padding: .8em .5em .5em .5em;
    text-decoration: none;
    color: #292929;
    text-shadow: 1px 1px 1px #cccccc;
}

#candymenu li {
    background-color: #c9c9c9;
    background-image: -webkit-gradient(linear, left top, left bottom, from(#c9c9c9),    to(#848484), color-stop(0.6, #a1a1a1));
}

#candymenu li:hover {
    background-color: #dc3d73;
    background-image: -webkit-gradient(linear, left top, left bottom, from(#dc3d73), to(#4c4c4c), color-stop(0.6, #474747));
}

#candymenu li:hover a {
    color: #e8e8e8;
    text-shadow: 1px 1px 0px #353535;
}

HTML

<div id="candymenu">    
    <ul>
        <li id="home">
            <a href="">Home</a></li>
        <li id="Gaming">
            <a href="">Gaming</a></li>
        <li id="Reviews">
            <a href="">Reviews</a></li>
        <li id="News">
            <a href="">news</a></li>
        <li id="Interviews">
            <a href="">interviews</a></li>
        <li id="download">
            <a href="">Download</a> </li>
        <li id="support">
            <a href="">Support</a></li>
        <li id="candy">
            <a href="">Candy</a></li>
        <li id="events">
            <a href="">Events</a></li>
    </ul>
</div>

现在我该如何缩小这个差距?

hi I have written css code to display menu bar. faced so many issues googled them and found solution too. But this one I couldn't find.
This is chrome output which has gaps in betweens menu boxes but if firefox theres no issue at all. its contact. how do I solve this?

CSS

#candymenu li {
    list-style-type: none;
    display: inline-block;
    width: 8.1em;
    float: center;
    text-align: center;
    font-family: "Lucida Grande", sans-serif;
    height: 3em;
}
#candymenu ul {
    width: 100%;
    margin:0 153px;

}   


#candymenu li a {
    display: inline-block;
    margin 150px;    
    padding: .5em .5em .5em .5em;
    text-decoration: none;
}

#candymenu li {
    list-style-type: none;
    display: inline-block;

    width: 8.1em;
    float: center;
    text-align: center;
    font-family: "Lucida Grande", sans-serif;
    height: 3em;
    border-right: 1px #818181 solid;
    -webkit-box-shadow: 1px 1px  #bbb;
    box-shadow: 1px 1px  1px #bbb;
}

#candymenu li a {
    display: inline-block;
    padding: .8em .5em .5em .5em;
    text-decoration: none;
    color: #292929;
    text-shadow: 1px 1px 1px #cccccc;
}

#candymenu li {
    background-color: #c9c9c9;
    background-image: -webkit-gradient(linear, left top, left bottom, from(#c9c9c9),    to(#848484), color-stop(0.6, #a1a1a1));
}

#candymenu li:hover {
    background-color: #dc3d73;
    background-image: -webkit-gradient(linear, left top, left bottom, from(#dc3d73), to(#4c4c4c), color-stop(0.6, #474747));
}

#candymenu li:hover a {
    color: #e8e8e8;
    text-shadow: 1px 1px 0px #353535;
}

HTML

<div id="candymenu">    
    <ul>
        <li id="home">
            <a href="">Home</a></li>
        <li id="Gaming">
            <a href="">Gaming</a></li>
        <li id="Reviews">
            <a href="">Reviews</a></li>
        <li id="News">
            <a href="">news</a></li>
        <li id="Interviews">
            <a href="">interviews</a></li>
        <li id="download">
            <a href="">Download</a> </li>
        <li id="support">
            <a href="">Support</a></li>
        <li id="candy">
            <a href="">Candy</a></li>
        <li id="events">
            <a href="">Events</a></li>
    </ul>
</div>

now how do i reduce that gap?

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

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

发布评论

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

评论(2

百善笑为先 2024-12-07 12:47:15

http://jsfiddle.net/VXsmd/
#candymenu li#candymenu li adisplay:inline-block 更改为 display:block然后为每个添加 float:left 。这似乎已在提供的小提琴中修复了它。

http://jsfiddle.net/VXsmd/
Change the display:inline-block of both #candymenu li and #candymenu li a to be display:block and then add float:left to each as well. That seems to have fixed it in the provided Fiddle.

昔日梦未散 2024-12-07 12:47:15

我认为内联块会导致依赖于空白的布局,这很糟糕。

因此,您基本上需要将所有 li 标签背靠背放置在一行上。就像这样:

<div id="candymenu">    
    <ul>
        <li id="home"><a href="">Home</a></li><li id="Gaming"><a href="">Gaming</a></li>

等等。

如果成功请告诉我!

I think inline-block results in white-space dependent layout, which sucks.

So you basically need to place all your li-tags back to back, on one single line. Like so:

<div id="candymenu">    
    <ul>
        <li id="home"><a href="">Home</a></li><li id="Gaming"><a href="">Gaming</a></li>

etc.

Let me know if it works out!

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