gpt4 book ai didi

css - html/css 菜单,子菜单显示在页面左侧

转载 作者:行者123 更新时间:2023-11-28 12:08:48 25 4
gpt4 key购买 nike

我正在尝试创建一个下拉菜单。但是在悬停时,我的子菜单出现在页面的左上角。我不知道我做错了什么。请帮忙。

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

最佳答案

它还影响了 Chrome。试试这个它应该工作:jsfiddle

#modernbricksmenu2 a{
display: inline-block;
font: bold 11px Arial;
color: white;
text-decoration: none;
margin: 0; /*Margin between each menu item*/
padding: 5px 10px;
background-color: black; /*Brown color theme*/
border-top: 1px solid white;
}

关于css - html/css 菜单,子菜单显示在页面左侧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19605800/

25 4 0