您好,登錄后才能下訂單哦!
這篇文章主要介紹了如何使用純css3實現的豎形二級導航,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
html代碼:
<div style="width: 700px; margin: auto;">
<div class="W1-h26">
<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-h26 {
padding: 0;
margin: 0;
border: 0;
line-height: 1;
}
.W1-h26 ul,
.W1-h26 ul li,
.W1-h26 ul ul {
list-style: none;
margin: 0;
padding: 0;
}
.W1-h26 ul {
position: relative;
z-index: 500;
float: left;
}
.W1-h26 ul li {
float: left;
min-height: 0.05em;
line-height: 1em;
vertical-align: middle;
position: relative;
}
.W1-h26 ul li.hover,
.W1-h26 ul li:hover {
position: relative;
z-index: 510;
cursor: default;
}
.W1-h26 ul ul {
visibility: hidden;
position: absolute;
top: 100%;
left: 0px;
z-index: 520;
width: 100%;
}
.W1-h26 ul ul li {
float: none;
}
.W1-h26 ul ul ul {
top: 0;
rightright: 0;
}
.W1-h26 ul li:hover > ul {
visibility: visible;
}
.W1-h26 ul ul {
top: 0;
left: 99%;
}
.W1-h26 ul li {
float: none;
}
.W1-h26 ul ul {
margin-top: 0.05em;
}
.W1-h26 {
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-h26 a {
display: block;
padding: 1em 1.3em;
color: #ffffff;
text-decoration: none;
text-transform: uppercase;
}
.W1-h26 > ul {
width: 13em;
}
.W1-h26 ul ul {
width: 13em;
}
.W1-h26 > ul > li > a {
border-right: 0.3em solid #1b9bff;
color: #ffffff;
}
.W1-h26 > ul > li > a:hover {
color: #ffffff;
}
.W1-h26 > ul > li a:hover,
.W1-h26 > ul > li:hover a {
background: #1b9bff;
}
.W1-h26 li {
position: relative;
}
.W1-h26 ul li.has-sub > a:after {
content: '»';
position: absolute;
rightright: 1em;
}
.W1-h26 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-h26 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-h26 ul ul {
-webkit-border-radius: 0 3px 3px 0;
-moz-border-radius: 0 3px 3px 0;
border-radius: 0 3px 3px 0;
}
.W1-h26 ul ul {
border: 1px solid #0082e7;
}
.W1-h26 ul ul a {
color: #ffffff;
}
.W1-h26 ul ul a:hover {
color: #ffffff;
}
.W1-h26 ul ul li {
border-bottom: 1px solid #0082e7;
}
.W1-h26 ul ul li:hover > a {
background: #4eb1ff;
color: #ffffff;
}
.W1-h26.align-rightright > ul > li > a {
border-left: 0.3em solid #1b9bff;
border-right: none;
}
.W1-h26.align-rightright {
float: rightright;
}
.W1-h26.align-rightright li {
text-align: rightright;
}
.W1-h26.align-rightright ul li.has-sub > a:before {
content: '+';
position: absolute;
top: 50%;
left: 15px;
margin-top: -6px;
}
.W1-h26.align-rightright ul li.has-sub > a:after {
content: none;
}
.W1-h26.align-rightright ul ul {
visibility: hidden;
position: absolute;
top: 0;
left: -100%;
z-index: 598;
width: 100%;
}
.W1-h26.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-h26.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-h26.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實現的豎形二級導航”這篇文章對大家有幫助,同時也希望大家多多支持億速云,關注億速云行業資訊頻道,更多相關知識等著你來學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。