chrome和firefox中的css导航菜单问题
你好,我已经编写了 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
http://jsfiddle.net/VXsmd/
将
#candymenu li
和#candymenu li a
的display:inline-block
更改为display:block
然后为每个添加float:left
。这似乎已在提供的小提琴中修复了它。http://jsfiddle.net/VXsmd/
Change the
display:inline-block
of both#candymenu li
and#candymenu li a
to bedisplay:block
and then addfloat:left
to each as well. That seems to have fixed it in the provided Fiddle.我认为内联块会导致依赖于空白的布局,这很糟糕。
因此,您基本上需要将所有 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:
etc.
Let me know if it works out!