我的网站导航菜单在 IE7 及更低版本中渲染得很糟糕 - 需要您的建议
我目前正在开发一个网站,该网站有一个简单的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从
#nav a
中删除float: right
,并将float: right
添加到#nav li
Remove
float: right
from your#nav a
, and addfloat: right
to#nav li
使用 display:inline 而不是 UL 和 Li 中的显示块 css
nav ul {
nav li {
如果您还有任何疑问,请留下评论,我可以纠正。
use display:inline instead of display block in UL and Li css
nav ul {
nav li {
if you have anymore concerns leave comment i can rectify.