我正在尝试创建一个下拉菜单。但是在悬停时,我的子菜单出现在页面的左上角。我无法弄清楚我做错了什么。请帮忙。
这是HTML:
<div id="modernbricksmenu2">
<ul>
<li id="current" style="margin-left: 0px"><a href="index.html">Home</a></li>
<li><a href="aboutus.html">About Coborn </a></li>
<li ><a href="services.html">Coborn Services</a>
<ul>
<li><a href="services.html">Sumbuusa Ewooma</a></li>
<li><a href="services.html">Sumbuusa Ewooma</a></li>
<li><a href="services.html">Sumbuusa Ewooma</a></li>
</ul>
</li>
<li><a href="careers.html">Cobon Careers</a></li>
<li><a href="training.html">Training</a></li>
<li><a href="contactus.html">Contact Us</a></li>
</ul>
</div>
这是CSS:
#modernbricksmenu2{
padding: 0;
width: 100%;
border-top: 5px solid #D25A0B; /*Brown color theme*/
background: transparent;
voice-family: "\"}\"";
voice-family: inherit;
}
#modernbricksmenu2 ul{
margin:0;
margin-left: 0px; /*margin between first menu item and left browser edge*/
padding: 0;
list-style: none;
}
#modernbricksmenu2 li{
display: inline;
margin: 0 0px 0 0;
padding: 0;
text-transform:uppercase;
position:relative;
}
#modernbricksmenu2 a{
float: left;
display: block;
font: bold 11px Arial;
color: white;
text-decoration: none;
margin: 0 1px 0 0; /*Margin between each menu item*/
padding: 5px 10px;
background-color: black; /*Brown color theme*/
border-top: 1px solid white;
}
#modernbricksmenu2 a:hover{
background-color: #D25A0B; /*Brown color theme*/
color: white;
}
#modernbricksmenu2 ul ul{
display:none;
position:absolute;
}
#modernbricksmenu2 ul ul li{
display:none;
position: relative;
float:none;
}
#modernbricksmenu2 ul li:hover > ul{
margin:0px;
padding:0px;
display:block;
}
#modernbricksmenu2 ul li:hover > ul li{
float:none;
display:block;
}
#modernbricksmenu2 ul li:hover > ul li a{
color:#336699;
min-width:150px;
}
#modernbricksmenu2 ul li:hover > ul li a:hover{
color:#fff;
}
#modernbricksmenu2 #current a{ /*currently selected tab*/
background-color: #D25A0B; /*Brown color theme*/
color: white;
border-color: #D25A0B; /*Brown color theme*/
}
另见此处:JsFiddle