当我将鼠标悬停在菜单上时会显示子菜单。如果我将鼠标悬停在子菜单上,则会显示子子菜单,但子菜单会消失。 防爆。 test test-1 test-2是菜单,test-2包含3个子菜单,如test-21 test-22 test-23。 test-21包含2个子子菜单,如test-211 test-212。如果我将鼠标悬停在test-2上,则会显示test-21,test-22,test-23。如果我将鼠标悬停在test-21上,则显示test-211,test-212但test-21消失。
答案 0 :(得分:0)
试试这个
@import url(http://fonts.googleapis.com/css?family=Bree+Serif);
h1,p {
text-align:center;
font-family: 'Bree Serif', 'serif';
}
h1 {
font-size:60px;
}
p {
font-size:20px;
}
nav { margin:100px auto; width:800px; }
nav ul {
padding:0;
margin:0;
list-style: none;
position: relative;
display:block;
}
nav ul li {
float:left;
display:list-item;
list-style: none;
background-color:#64abfb;
border-bottom: 5px solid #2ecc71;
}
nav ul li a {
display:block;
padding:15px 10px;
color:#FFF;
font-size:20px;
text-decoration:none;
font-family: 'Bree Serif', 'serif';
}
li a:hover { background-color: #2ecc71; }
/* Change this in order to change the Dropdown symbol */
li > a:after { content: ' »'; }
li > a:only-child:after { content: ''; }
/* The Dropdown Styles */
/* =================== */
/* Hide Dropdowns by Default */
nav ul ul {
display: none;
position: absolute; top: 58px;
}
/* Display Dropdowns on Hover */
nav ul li:hover > ul {
display:list-item;
}
/* Fisrt Tier Dropdown */
nav ul ul li {
width:170px;
float:none;
position: relative;
border-bottom:none;
}
/* Second, Third and more Tiers */
nav ul ul ul li {
position: absolute relative;
top:-58px;
left:170px;
}

<p>Dropdowns are marked with " » "<br/>
</p>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">WordPress</a>
<!-- First Tier Drop Down -->
<ul>
<li><a href="#">Themes</a></li>
<li><a href="#">Plugins</a></li>
<li><a href="#">Tutorials</a></li>
</ul>
</li>
<li><a href="#">Web Design</a>
<!-- First Tier Drop Down -->
<ul>
<li><a href="#">Resources</a></li>
<li><a href="#">Links</a></li>
<li><a href="#">Tutorials</a>
<!-- Second Tier Drop Down -->
<ul>
<li><a href="#">HTML/CSS</a></li>
<li><a href="#">jQuery</a></li>
<li><a href="#">Other</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#">Graphic Design</a></li>
<li><a href="#">Inspiration</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">About</a></li>
</ul>
</nav>
&#13;