一款纯css3实现的竖形二级导航的实例教程
程序员文章站
2022-03-13 09:09:28
这篇文章主要为大家介绍了一款纯css3实现的竖形二级导航的实例教程,这款导航菜单特色是可以是无限级。下面有代码,不会的朋友可以过来借鉴学习哦... 14-12-11...
之前为大家分享了好多导航菜单。今天给大家带来一款纯css3实现的竖形二级导航。这款导航菜单可以是无限级。一起看下效果图:
实现的代码。
html代码:
xml/html code复制内容到剪贴板
- <div style="width: 700px; margin: auto;">
- <div class="w1-h16">
- <ul>
- <li class="has-sub"><a href="#">menu 1</a>
- <ul>
- <li class="has-sub"><a href="#">submenu 1.1</a>
- <ul>
- <li><a href="#">submenu 1.1.1</a></li>
- <li class="has-sub"><a href="#">submenu 1.1.2</a>
- <ul>
- <li><a href="#">submenu 1.1.2.1</a></li>
- <li><a href="#">submenu 1.1.2.2</a></li>
- </ul>
- </li>
- </ul>
- </li>
- <li><a href="#">submenu 1.2</a></li>
- </ul>
- </li>
- <li class="has-sub"><a href="#">menu 2</a>
- <ul>
- <li><a href="#">submenu 2.1</a></li>
- <li><a href="#">submenu 2.2</a></li>
- </ul>
- </li>
- <li class="has-sub"><a href="#">menu 3</a>
- <ul>
- <li><a href="#">submenu 3.1</a></li>
- <li><a href="#">submenu 3.2</a></li>
- </ul>
- </li>
- </ul>
- </div>
- </div>
css3代码:
css code复制内容到剪贴板
- .w1-h16 {
- padding: 0;
- margin: 0;
- border: 0;
- line-height: 1;
- }
- .w1-h16 ul,
- .w1-h16 ul li,
- .w1-h16 ul ul {
- list-style: none;
- margin: 0;
- padding: 0;
- }
- .w1-h16 ul {
- position: relative;
- z-index: 500;
- float: left;
- }
- .w1-h16 ul li {
- float: left;
- min-height: 0.05em;
- line-height: 1em;
- vertical-align: middle;
- position: relative;
- }
- .w1-h16 ul li.hover,
- .w1-h16 ul li:hover {
- position: relative;
- z-index: 510;
- cursor: default;
- }
- .w1-h16 ul ul {
- visibility: hidden;
- position: absolute;
- top: 100%;
- left: 0px;
- z-index: 520;
- width: 100%;
- }
- .w1-h16 ul ul li {
- float: none;
- }
- .w1-h16 ul ul ul {
- top: 0;
- rightright: 0;
- }
- .w1-h16 ul li:hover > ul {
- visibility: visible;
- }
- .w1-h16 ul ul {
- top: 0;
- left: 99%;
- }
- .w1-h16 ul li {
- float: none;
- }
- .w1-h16 ul ul {
- margin-top: 0.05em;
- }
- .w1-h16 {
- width: 13em;
- background: #333333;
- font-family: 'oxygen mono', tahoma, arial, sans-serif;
- zoom: 1;
- }
- .w1-h16:before {
- content: '';
- display: block;
- }
- .w1-h16:after {
- content: '';
- display: table;
- clear: both;
- }
- .w1-h16 a {
- display: block;
- padding: 1em 1.3em;
- color: #ffffff;
- text-decoration: none;
- text-transform: uppercase;
- }
- .w1-h16 > ul {
- width: 13em;
- }
- .w1-h16 ul ul {
- width: 13em;
- }
- .w1-h16 > ul > li > a {
- border-right: 0.3em solid #1b9bff;
- color: #ffffff;
- }
- .w1-h16 > ul > li > a:hover {
- color: #ffffff;
- }
- .w1-h16 > ul > li a:hover,
- .w1-h16 > ul > li:hover a {
- background: #1b9bff;
- }
- .w1-h16 li {
- position: relative;
- }
- .w1-h16 ul li.has-sub > a:after {
- content: '»';
- position: absolute;
- rightright: 1em;
- }
- .w1-h16 ul ul li.first {
- -webkit-border-radius: 0 3px 0 0;
- -moz-border-radius: 0 3px 0 0;
- border-radius: 0 3px 0 0;
- }
- .w1-h16 ul ul li.last {
- -webkit-border-radius: 0 0 3px 0;
- -moz-border-radius: 0 0 3px 0;
- border-radius: 0 0 3px 0;
- border-bottom: 0;
- }
- .w1-h16 ul ul {
- -webkit-border-radius: 0 3px 3px 0;
- -moz-border-radius: 0 3px 3px 0;
- border-radius: 0 3px 3px 0;
- }
- .w1-h16 ul ul {
- border: 1px solid #0082e7;
- }
- .w1-h16 ul ul a {
- color: #ffffff;
- }
- .w1-h16 ul ul a:hover {
- color: #ffffff;
- }
- .w1-h16 ul ul li {
- border-bottom: 1px solid #0082e7;
- }
- .w1-h16 ul ul li:hover > a {
- background: #4eb1ff;
- color: #ffffff;
- }
- .w1-h16.align-rightright > ul > li > a {
- border-left: 0.3em solid #1b9bff;
- border-right: none;
- }
- .w1-h16.align-rightright {
- float: rightright;
- }
- .w1-h16.align-rightright li {
- text-align: rightright;
- }
- .w1-h16.align-rightright ul li.has-sub > a:before {
- content: '+';
- position: absolute;
- top: 50%;
- left: 15px;
- margin-top: -6px;
- }
- .w1-h16.align-rightright ul li.has-sub > a:after {
- content: none;
- }
- .w1-h16.align-rightright ul ul {
- visibility: hidden;
- position: absolute;
- top: 0;
- left: -100%;
- z-index: 598;
- width: 100%;
- }
- .w1-h16.align-rightright ul ul li.first {
- -webkit-border-radius: 3px 0 0 0;
- -moz-border-radius: 3px 0 0 0;
- border-radius: 3px 0 0 0;
- }
- .w1-h16.align-rightright ul ul li.last {
- -webkit-border-radius: 0 0 0 3px;
- -moz-border-radius: 0 0 0 3px;
- border-radius: 0 0 0 3px;
- }
- .w1-h16.align-rightright ul ul {
- -webkit-border-radius: 3px 0 0 3px;
- -moz-border-radius: 3px 0 0 3px;
- border-radius: 3px 0 0 3px;
- }
上一篇: 五款漂亮的纯CSS3动画按钮的实例教程
下一篇: JS 只创建一个元素