gpt4 book ai didi

html - 需要制作 3 级纯 css 菜单

转载 作者:行者123 更新时间:2023-11-28 17:53:09 25 4
gpt4 key购买 nike

我制作了 2 个级别的纯 css 菜单。但现在我需要将其制作为 3 个级别。我尝试了很多次但不适合我。这是 jsfiddle .我不需要任何 jquery 代码,只需要纯 css。

CSS

#menu {
width: 980px;
height: 30px;
float: left;
border-top: dashed 1px #d8d8d8;
margin-left: 7px;
}
#menu ul.Mainmenu {
width: 996px;
margin: 0px;
padding: 0px;
margin-top: 10px;
}
#menu ul.Mainmenu li {
float: left;
list-style: none;
margin-right: 20px;
font-family: Verdana, Geneva, sans-serif;
font-size: 14px;
color: #860300;
margin-right: 16px\9; /* IE8 and below */
position: relative;
height: 30px;
}
#menu ul.Mainmenu li a {
text-decoration: none;
font-family: Verdana, Geneva, sans-serif;
font-size: 13px;
color: #860300;
}
ul li ul {
padding: 0;
position: absolute;
top: 25px;
left: -10px;
width: 190px;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;

opacity: 0;
visibility: hidden;
-webkit-transiton: opacity 0.5s;
-moz-transition: opacity 0.5s;
-ms-transition: opacity 0.5s;
-o-transition: opacity 0.5s;
-transition: opacity 0.5s;
z-index: 100000;
width: 200px;
background-color: #FFF;
padding: 7px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
ul li ul li {

color: #fff;
float: left;
width: 190px;
height: auto !important;
min-height: 20px;
margin-bottom: 9px;
line-height: 18px;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
padding-top: 3px;
padding-left: 3px;
}
ul li ul li a {

color: #fff;
font-size: 12px !important;
}
ul li ul li:hover {
background: #820B06;
color: #FFF;
}
ul li ul li:hover a {
color: #FFF !important;
}
ul li:hover ul {

opacity: 1;
visibility: visible;
}

谢谢大家

最佳答案

查看此 example

CSS

#nav ul{
margin:0;
padding:0;
list-style:none;
}
#nav ul li{
margin:0;
padding:10px 20px;
position:relative;
height:20px;
line-height:20px;
background-color:#EEE;
}
#nav > ul > li {
float: left;
height:30px;
line-height:30px;
background-color:#CCC;
}
#nav li > ul{
visibility:hidden;
width:200px;
position: absolute;
top:0px;
left:200px;
border-left:1px solid #000;
}
#nav > ul > li > ul{
top:50px;
left:0;
}
#nav li:hover{
background-color:#999;
}
#nav li:hover > ul{
visibility:visible;
}

html

<div id="nav">
<ul>
<li>Level 1
<ul>
<li>Level 2-1</li>
<li>Level 2-2
<ul>
<li>Level 3-1</li>
<li>Level 3-2</li>
</ul>
</li>
</ul>
</li>
</ul>

关于html - 需要制作 3 级纯 css 菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21878507/

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