这就是我所拥有的:http://jsfiddle.net/QKThn/1/
下拉菜单在Chrome中运行良好,但嵌套UL(弹出的列表:悬停)的位置并不直接位于Internet Explorer或Firefox中的父LI下方。在IE和FF中,嵌套的UL菜单拥抱整个NAV的左侧而不是其父LI。
知道我错过了什么吗?
CSS:
nav {
clear: none;
float: right;
font-family: 'Open Sans';
line-height: 120px;
}
nav ul {
position: relative;
display: inline-table;
}
nav li {
display: inline;
padding-left: 5px;
position: relative;
}
nav a, nav a:visited {
font-size: 14px;
padding: 8px;
text-transform: uppercase;
text-decoration: none;
color: #005f99;
}
nav a:hover, nav a:active {
color: #fff;
background-color: #7fafcc;
/*border-bottom: 2px solid #5cbc51;*/
}
nav li.current a {
color: #fff;
background-color: #7fafcc;
/*border-bottom: 2px solid #5cbc51;*/
}
nav li ul {
display: none;
}
nav ul li:hover > ul {
display: block;
}
nav ul ul {
position: absolute;
top: 29px;
padding: 0;
margin: 0 0 0 5px;
background-color: #005f99;
width: 200px;
z-index: 999;
}
nav ul ul li {
padding: 0;
margin: 0;
float: none;
position: relative;
display: block;
clear: both;
color: #fff;
border-left: 4px solid #fff;
border-bottom: 1px solid #fff;
}
nav ul ul li:hover {
background: #22284f;
}
nav ul ul li a, nav ul ul li a:visited {
font-size: 14px;
line-height: 20px;
text-transform: uppercase;
text-decoration: none;
color: #fff;
display: block;
width: 100%;
}
nav ul ul li a:hover, nav ul ul li a:active {
color: #fff;
background-color: transparent;
}
nav ul ul li {
line-height: 40px;
}
nav ul ul li { border-color: #35b5eb; }
nav ul ul li+li { border-color: #0acf67; }
nav ul ul li+li+li { border-color: #f2c13f; }
nav ul ul li+li+li+li { border-color: #a5c950; }
nav ul ul li+li+li+li+li { border-color: #ab50c9; }
nav ul ul li+li+li+li+li+li { border-color: #eb5b4c; }
HTML:
<nav> <ul>
<li class="current"><a href="" title="">home</a></li>
<li><a href="" title="">about us</a>
<ul>
<li><a href="">Our Mission</a></li>
<li><a href="">History & Impact</a></li>
<li><a href="">Financials</a></li>
<li><a href="">Staff</a></li>
<li><a href="">Board Members</a></li>
<li><a href="">Careers & Jobs</a></li>
</ul>
</li>
<li><a href="" title="">get involved</a></li>
<li><a href="" title="">stores</a>
<ul>
<li><a href="">Our Mission</a></li>
<li><a href="">History & Impact</a></li>
<li><a href="">Financials</a></li>
<li><a href="">Staff</a></li>
<li><a href="">Board Members</a></li>
<li><a href="">Careers & Jobs</a></li>
</ul>
</li>
<li><a href="" title="">contact</a></li>
</ul>
</nav>
答案 0 :(得分:0)
将left: 0;
添加到nav ul ul
jsfiddle - http://jsfiddle.net/QKThn/3/
CSS
nav ul ul {
position: absolute;
top: 29px;
left: 0;
padding: 0;
margin: 0 0 0 5px;
background-color: #005f99;
width: 200px;
z-index: 999;
}