我得到了一个带有这段代码的 CSS3 菜单:
HTML:
<div id="navi">
<ul>
<li><a href="#">First</a></li>
<li class="active"><a href="#">Second</a>
<ul class="child">
<li><a href="#">First child</a></li>
</ul>
</li>
<li><a href="#">Third</a></li>
</ul>
</div>
CSS:
#navi {
height: auto;
width: auto;
}
#navi ul {
margin: 0px;
padding: 0px;
list-style-type: none;
}
#navi ul li {
float: left;
position: relative;
}
#navi ul li a {
line-height: 30px;
text-decoration: none;
text-align: center;
display: block;
width: 100px;
height: 30px;
border: thin solid #999;
color: #FFF;
background-color: #0CF;
-webkit-transition: all 1s;
-moz-transition: all 1s;
-ms-transition: all 1s;
-o-transition: all 1s;
transition: all 1s;
}
#navi ul li a:hover {
background-color: #0C3;
}
#navi ul li ul {
position: absolute;
-webkit-transition: height 1s linear 0s;
-moz-transition: height 1s linear 0s;
-ms-transition: height 1s linear 0s;
-o-transition: height 1s linear 0s;
transition: height 1s linear 0s;
height: 0px;
overflow:hidden;
}
#navi ul li:hover ul {
height: 100px;
-webkit-transition: height 1s linear 0s;
-moz-transition: height 1s linear 0s;
-ms-transition: height 1s linear 0s;
-o-transition: height 1s linear 0s;
transition: height 1s linear 0s;
}
小提琴Here
现在我希望菜单不是水平的。它应该是垂直的。我试图删除float:left;
,但子菜单不显示。子菜单应按下下方的所有菜单项。有什么建议么?会很好。