標籤:padding 目的 ima hover title -- class htm list
動態網站第一步:動態下拉式功能表
關鍵點:
overflow:hidden
max-height
xx:hover {} 設定當滑鼠移上之後的效果
transition: 設定過度時間
cursor: 設定滑鼠效果
opacity: 設定透明度 0-1
如所示
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
*{
margin: 0px;
padding: 0px;
list-style:none ;
font-family:"微軟雅黑";
text-shadow: royalblue 5px 5px; /* 陰影*/
}
.top-nav,#nav-lv1{
border-radius: 10px; /*邊框為圓形*/
}
.top-container{
width: 100%;
height:40px;
background-color: cyan;
position: relative;
}
.top-nav{
width: 600px;
height: 40px;
margin:0px auto; /*置中*/
position: relative;
}
#nav-lv1{
width: 150px;
max-height:40px; /*最大高度*/
background-color: palegreen;
float: left;
text-align: center;
vertical-position: middle;
line-height: 40px;
overflow: hidden; /*實現動態導覽列關鍵點*/
}
#nav-lv1:hover{
max-height: 400px; /*最大高度*/
transition: 1s; /*過度效果*/
cursor:pointer; /* 滑鼠改小手*/
background: greenyellow;
}
#nav-lv1 li:hover{
background-color: greenyellow;
text-decoration: underline;
}
#nav-lv1 ul{
background-color: white;
opacity: 0.9; /* 設定透明度* 目的是防止擋住底下的文字/
}
</style>
</head>
<body>
<div class="top-container">
<div class="top-nav">
<div id="nav-lv1">HTML
<ul>
<li>1</li> <!--可換成<a></a>標籤-->
<li>2</li>
<li>31</li>
<li>41</li>
</ul>
</div>
<div id="nav-lv1">JavaScript
<ul>
<li>1</li>
<li>31</li>
<li>41</li>
</ul>
</div>
<div id="nav-lv1">CSS
<ul>
<li>1</li>
<li>2</li>
<li>41</li>
</ul>
</div>
<div id="nav-lv1">Jquery
<ul>
<li>1</li>
<li>2</li>
<li>31</li>
<li>41</li>
</ul>
</div>
</div>
</div>
</body>
</html>
CSS寫動態下拉式功能表 -----2017-03-27