为什么子菜单中的最后一个列表项低于Chrome中的其余列表项,但在Firefox中对齐?
JSFIDDLE字体变为红色以显示
我已经尝试了所有我能想到的填充,边距,垂直对齐,最后一个孩子等等。困惑。谢谢。
#hmenuWrapper {
width: 100%;
}
#hmenu, #hmenu ul, #hmenu ul li, #hmenu ul li a {
padding: 0;
margin: 0;
line-height: 1;
font-family: 'Arial', sans-serif;
}
#hmenu:before, #hmenu:after, #hmenu > ul:before, #hmenu > ul:after {
content: '';
display: table;
}
#hmenu:after, #cssmenu > ul:after {
clear: both;
}
#hmenu {
position: relative;
top: 0px;
left: 180px;
zoom: 1;
height: 60px;
width: 740px;
background: url(../media/images/bottom-bg.png) repeat-x center bottom;
border-radius: 2px;
}
#hmenu ul {
background: url(../media/images/nav-bg.png) repeat-x 0px 4px;
height: 69px;
}
#hmenu ul li {
float: left;
list-style: none;
}
#hmenu ul li a {
display: block;
height: 37px;
padding: 17px 14px 0;
margin: 4px 0px 0;
border-radius: 2px 2px 0 0;
text-decoration: none;
font-size: 15px;
color: white;
text-shadow: 0 1px 1px rgba(0, 0, 0, .75);
font-weight: 400;
opacity: .9;
}
#hmenu ul li:first-child a {
margin: 4px 0px 0 0;
}
#hmenu ul li:last-child {
background-color: #168b09;
}
#hmenu ul li a:hover {
background: url(../media/images/colorHover.png) center bottom;
display: block;
height: 37px;
margin-top: 0px;
padding-top: 20px;
color: #616161;
text-shadow: 0 1px 1px rgba(255, 255, 255, .35);
opacity: 1;
}
#hmenu ul li.active a {
background: url(../media/images/color.png) center bottom;
display: block;
height: 37px;
margin-top: 0px;
padding-top: 20px;
color: #616161;
text-shadow: 0 1px 1px rgba(255, 255, 255, .35);
opacity: 1;
}
#nav-wrap {
position: relative;
left: 180px;
top: -3px;
zoom: 1;
height: 40px;
width: 740px;
float: left;
background: url(../media/images/colorinv.png);
}
#nav {
display: inline;
height: 40px;
width: 100%;
}
#nav a:hover {
color: #444444;
text-decoration: none;
}
#nav li:hover {
background: url(../media/images/nav-bginvHover.png);
}
#nav a li:hover {
color: #444444;
}
#nav ui li a {
height: 40px;
width: 185px;
}
.nav-item {
float: left;
height: 40px;
line-height: 40px;
text-align: center;
text-decoration: none;
width: 185px;
list-style-type: none;
color: white;
}
.nav-item a {
height: 40px;
width: 185px;
}
#nav li.nav-sel {
float: left;
height: 40px;
line-height: 40px;
text-align: center;
width: 185px;
list-style-type: none;
color: white;
font-family: 'Arial', sans-serif;
background: url(../media/images/nav-bginv.png);
}
#nav li.nav-sel a {
color: white;
height: 40px;
width: 185px;
line-height: 40px;
}
答案 0 :(得分:1)
因为#nav display:inline
。
将其设置为display:table-row;
答案 1 :(得分:1)
将2q
添加到您的CSS中,请参阅小提琴:https://jsfiddle.net/zjckk9uL/4/
答案 2 :(得分:1)
此外,从第42行开始,您的HTML无效。您不应使用Anchor(或任何内容)包装List Item。锚点应该在List Item中。
<ul id="nav">
<a href="pages/companyServices.html"><li class="nav-item">Company Services</li></a>
<a href="pages/skyAdvantages.html"><li class="nav-item">Sky Advantages</li></a>
<a href="pages/customerRecognition.html"><li class="nav-item">Customer Recognition</li></a>
<a href="pages/newsReleases.html"><li class="nav-item">News Releases</li></a>
</ul>
到
<ul id="nav">
<li class="nav-item"><a href="pages/companyServices.html">Company Services</a></li>
<li class="nav-item"><a href="pages/skyAdvantages.html">Sky Advantages</a></li>
<li class="nav-item"><a href="pages/customerRecognition.html">Customer Recognition</a></li>
<li class="nav-item"><a href="pages/newsReleases.html">News Releases</a></li>
</ul>