CSS學習案例(14):下拉導航選單
<div class="container">
<nav class="menu">
<ul>
<li><a href="#">Home</a></li>
<li>
<a href="#">About Me</a>
<div class="sub">
<ul>
<li> <a href="#">Photo</a></li>
<li> <a href="#">Video</a></li>
</ul>
</div>
</li>
<li>
<a href="#">Articles on HTML5&CSS3</a>
<div class="sub">
<ul>
<li> <a href="#">Difference
between SVG vs. Canvas</a></li>
<li> <a href="#">New features in HTML5</a></li>
<li> <a href="#">Creating
links to sections within a webpage</a></li>
</ul>
</div>
</li>
<li><a href="#">News</a></li>
<li><a href="#">Contact Us</a></li>
</ul>
</nav>
</div>
*{margin: 0;padding: 0;}
body{
height: 100vh;width: 100vw;
background-color: #2c3e50;
display: flex;
justify-content: center;
align-items: center;
}
.container{
transform: translateY(-100px);
text-align: center;
font-weight: bold;
color: #fff;
}
.menu>ul>li{
width: auto;
list-style: none;
float: left;
position: relative;
}
.menu>ul>li>a{
display: block;
background-color: #0984e3;
text-decoration: none;
color: #fff;
font-size: 20px;
font-weight: bold;
line-height: 60px;
padding: 0 20px;
min-width: 100px;
transition: all .5s ease-in-out;
}
.menu>ul>li:hover>a{
background-color: #000;
}
.sub>ul>li {
border-bottom: 1px solid #777;
}
.sub>ul>li:last-child {
border-bottom: none;
}
.sub>ul {
list-style: none;
transform: translateY(-100%);
transition: all .5s ease-in-out;
}
.menu>ul>li:hover .sub{
height: auto;
}
.menu>ul>li:hover .sub>ul{
transform: translateY(0);
}
.sub{
position: absolute;
width : 100%;
height: 0;
overflow: hidden;
}
.sub>ul>li>a{
display: block;
background-color: #333;
text-decoration: none;
color: #fff;
font-size: 20px;
font-weight: bold;
line-height: 60px;
padding: 0 20px;
}
.sub>ul>li>a:hover{
background-color: #555;
}
案例參考:學習:純CSS製作二級下拉導航選單
相關文章
- CSS導航欄及下拉選單CSS
- 純css製作導航下拉選單CSS
- CSS三級下拉導航選單詳解CSS
- jq+css+html打造下拉導航選單例項CSSHTML單例
- CSS3動畫效果下拉導航選單效果CSSS3動畫
- JavaScript slide下拉導航選單效果JavaScriptIDE
- CSS垂直導航選單CSS
- CSS 動態導航選單CSS
- jQuery 淡入淡出效果下拉導航選單jQuery
- JavaScript下拉摺疊導航選單講解JavaScript
- 滑鼠懸浮緩慢下拉導航選單
- CSS多級導航選單效果CSS
- CSS垂直三級導航選單CSS
- jQuery 緩衝效果二級導航下拉選單jQuery
- 二級下拉導航選單製作詳解
- bootstrap 選單導航選單nav li滑鼠移入hover下拉顯示boot
- [開發教程] 第32講:Bootstrap導航選單裡的下拉選單boot
- CSS 可伸縮圓角導航選單CSS
- CSS3麵包屑導航選單CSSS3
- 純CSS打造淘寶導航選單欄CSS
- CSS3垂直摺疊導航選單CSSS3
- CSS水平導航選單製作詳解CSS
- CSS 水平導航選單製作詳解CSS
- CSS3橫向導航選單效果CSSS3
- 點選平滑下拉展開摺疊樹形導航選單
- PbootCMS導航選單-導航選單的使用教程boot
- CSS 二級下拉選單CSS
- CSS二級下拉選單CSS
- JavaScript實現HTML導航欄下拉選單[懸浮顯示]JavaScriptHTML
- jquery-滑鼠經過導航條,顯示二級下拉選單jQuery
- css滑鼠懸浮下拉選單效果CSS
- jQuery與CSS二級下拉選單jQueryCSS
- HTML+CSS實現下拉選單HTMLCSS
- checkbox及css實現點選下拉選單CSS
- CSS3立體導航選單程式碼例項CSSS3
- css3滑鼠懸浮展開收縮導航選單CSSS3
- 導航選單(動畫)--- jQuery動畫jQuery
- JavaScript 三級導航選單JavaScript