html 折叠下拉菜单
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html 折叠下拉菜单相关的知识,希望对你有一定的参考价值。
.nav {
margin-bottom: 48px;
}
.nav ul {
*zoom: 1;
list-style: none;
margin: 0;
padding: 0;
background: #333;
}
.nav ul:before,
.nav ul:after {
content: "";
display: table;
}
.nav ul:after {
clear: both;
}
.nav ul > li {
float: left;
position: relative;
}
.nav a {
display: block;
padding: 10px 20px;
line-height: 1.2em;
color: #fff;
border-left: 1px solid #595959;
}
.nav a:hover {
text-decoration: none;
background: #595959;
}
.nav li ul {
background: #273754;
}
.nav li ul li {
width: 200px;
}
.nav li ul a {
border: none;
}
.nav li ul a:hover {
background: rgba(0, 0, 0, 0.19999999999999996);
}
/* Not Animated
============================== */
.nav1 ul > li:hover ul {
left: 0;
}
.nav1 li ul {
position: absolute;
left: -9999em;
top: 36px;
z-index: 1;
}
/* Fade In and Out
============================== */
.nav2 ul > li:hover ul {
visibility: visible;
opacity: 1;
filter: alpha(opacity=100);
}
.nav2 li ul {
position: absolute;
left: 0;
top: 36px;
z-index: 1;
visibility: hidden;
opacity: 0;
filter: alpha(opacity=0);
-webkit-transition: 200ms ease;
-moz-transition: 200ms ease;
-o-transition: 200ms ease;
transition: 200ms ease;
}
/* Fold Out
============================== */
.nav5 ul > li:hover ul {
max-height: 1000px;
-webkit-transform: perspective(400) rotate3d(0, 0, 0, 0);
}
.nav5 li ul {
position: absolute;
left: 0;
top: 36px;
z-index: 1;
max-height: 0;
overflow: hidden;
-webkit-transform: perspective(400) rotate3d(1, 0, 0, -90deg);
-webkit-transform-origin: 50% 0;
-webkit-transition: 350ms;
-moz-transition: 350ms;
-o-transition: 350ms;
transition: 350ms;
}
<h2>Fold Out</h2>
<nav class="nav nav5">
<ul>
<li>
<a href="#">Nav Item</a>
<ul>
<li><a href="#">Subnav Item</a></li>
<li><a href="#">Subnav Item</a></li>
<li><a href="#">Subnav Item</a></li>
</ul>
</li>
<li>
<a href="#">Nav Item</a>
<ul>
<li><a href="#">Subnav Item</a></li>
<li><a href="#">Subnav Item</a></li>
<li><a href="#">Subnav Item</a></li>
</ul>
</li>
<li>
<a href="#">Nav Item</a>
<ul>
<li><a href="#">Subnav Item</a></li>
<li><a href="#">Subnav Item</a></li>
<li><a href="#">Subnav Item</a></li>
</ul>
</li>
<li>
<a href="#">Nav Item</a>
<ul>
<li><a href="#">Subnav Item</a></li>
<li><a href="#">Subnav Item</a></li>
<li><a href="#">Subnav Item</a></li>
</ul>
</li>
<li>
<a href="#">Nav Item</a>
<ul>
<li><a href="#">Subnav Item</a></li>
<li><a href="#">Subnav Item</a></li>
<li><a href="#">Subnav Item</a></li>
</ul>
</li>
</ul>
</nav>
以上是关于html 折叠下拉菜单的主要内容,如果未能解决你的问题,请参考以下文章
如何在折叠的导航栏中默认打开 Bootstrap 3 下拉菜单