gpt4 book ai didi

html - 水平 float 元素在 chrome 中被向下推,但在 firefox 中没有

转载 作者:太空宇宙 更新时间:2023-11-03 22:59:20 24 4
gpt4 key购买 nike

为什么子菜单中的最后一个列表项在 Chrome 中低于其余列表项,但在 Firefox 中却对齐?

JSFIDDLE字体变成红色以提高可见度

ACTUAL SITE

我已经尝试了所有我能想到的填充、边距、垂直对齐、最后一个子元素等。感到困惑。谢谢。

#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;
}

最佳答案

#nav 中删除display: inline,不需要:https://jsfiddle.net/ry5mLkaL/1/

此外,您的 HTML 从第 42 行开始无效。您不应该用 anchor (或任何东西)包裹列表项。 anchor 应在列表项内。

 <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>

关于html - 水平 float 元素在 chrome 中被向下推,但在 firefox 中没有,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37122107/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com