我的网站导航菜单在 IE7 及更低版本中渲染得很糟糕 - 需要您的建议

发布于 2024-09-18 23:38:07 字数 1480 浏览 3 评论 0原文

我目前正在开发一个网站,该网站有一个简单的 css 导航菜单,其 css 如下所示:

#nav {
    background: #ffffff;
    list-style: none; 
    width:300px;
    height:100px;
    float:right;

    border-color: #600;
    border-width: 1px 1px 1px 1px;
    border-style: solid;

    }

#nav a {
    color: #bf511e;
    text-decoration: none;
    margin: 55px 15px 0px;
    font: bold 18px/100% georgia, verdana, Helvetica, sans-serif;
    font-style: italic;
    float:right;
    }

#nav ul {
    clear:left;
    list-style:none;
    margin:0;
    padding:0;
    position:relative;
    text-align:right;
    display:block;
    }

#nav li {
    margin: 0 auto;
    display:block;
    text-align:right;
    }

#nav a:hover {
    color: #ea895c;
    }

HTML 代码如下所示:

<div id="nav">  
                <ul>
                        <li><a href="/blog">Blog</a></li>
                        <li><a href="#">About</a></li>
                        <li><a href="/">Home</a></li>
                </ul>
            </div>

结果是,

在 Chrome、FF、Opera 和 IE8 上(我认为),它看起来不错(所以让我只添加一个超链接,所以我已将您链接到损坏的图像)

在 IE7 及更低版本上,它看起来像这样: http://tinypic.com/r/2r5u5a1/7

有什么明显的东西吗我这里做错了吗?或者这是一个已知的错误?

我几乎是 CSS 布局的初学者,所以帮助我指明正确的方向将不胜感激。谷歌搜索后没有遇到类似的问题。

I'm working on a site currently which has a simple css nav menu with css that looks like so:

#nav {
    background: #ffffff;
    list-style: none; 
    width:300px;
    height:100px;
    float:right;

    border-color: #600;
    border-width: 1px 1px 1px 1px;
    border-style: solid;

    }

#nav a {
    color: #bf511e;
    text-decoration: none;
    margin: 55px 15px 0px;
    font: bold 18px/100% georgia, verdana, Helvetica, sans-serif;
    font-style: italic;
    float:right;
    }

#nav ul {
    clear:left;
    list-style:none;
    margin:0;
    padding:0;
    position:relative;
    text-align:right;
    display:block;
    }

#nav li {
    margin: 0 auto;
    display:block;
    text-align:right;
    }

#nav a:hover {
    color: #ea895c;
    }

with the HTML code looking like:

<div id="nav">  
                <ul>
                        <li><a href="/blog">Blog</a></li>
                        <li><a href="#">About</a></li>
                        <li><a href="/">Home</a></li>
                </ul>
            </div>

The result is that,

on Chrome, FF, Opera and IE8 (I think), it looks fine (SO lets me add only one hyperlink, so I've linked you to the broken image)

On IE7 and lower, it looks like so:
http://tinypic.com/r/2r5u5a1/7

Is there something obvious I'm doing wrong here? or is this a known bug?

I'm pretty much a beginner to CSS layouts, so help pointing me in the right direction will be appreciated. Didn't come across similar issues after some googling.

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

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

发布评论

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

评论(2

请持续率性 2024-09-25 23:38:07

#nav a 中删除 float: right,并将 float: right 添加到 #nav li

Remove float: right from your #nav a, and add float: right to #nav li

柠栀 2024-09-25 23:38:07

使用 display:inline 而不是 UL 和 Li 中的显示块 css

nav ul {

clear:left; 
list-style:none; 
margin:0; 
padding:0; 
position:relative; 
text-align:right; 
display:inline; 
} 

nav li {

margin: 0 auto; 
display:inline; 
text-align:right; 
} 

如果您还有任何疑问,请留下评论,我可以纠正。

use display:inline instead of display block in UL and Li css

nav ul {

clear:left; 
list-style:none; 
margin:0; 
padding:0; 
position:relative; 
text-align:right; 
display:inline; 
} 

nav li {

margin: 0 auto; 
display:inline; 
text-align:right; 
} 

if you have anymore concerns leave comment i can rectify.

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