## css下拉欄的幾種設計
>### 方式一:
**原理:設置導航欄高度,隱藏其超出部分**
效果如圖:

>#### html代碼:
```
<div class="box">
<ul>
<li>this is 1</li>
<li>this is 2</li>
<li>this is 3</li>
<li>this is 4</li>
<li>this is 5</li>
</ul>
</div>
```
>#### css代碼:
```
* {
margin: 0;
padding: 0;
}
.box {
width: 200px;
height: 50px; /*導航條高度設置成50px*/
margin: 40px;
overflow: hidden; /*超出導航條部分隱藏*/
cursor: pointer;
transition: all 0.35s; /*設置動畫時間*/
}
.box ul {
list-style: none;
padding: 0;
}
.box ul li {
width: 200px;
height: 50px;
line-height: 50px;
text-align: center;
background: black;
color: white;
}
.box:hover{
height: 250px;
}
.box ul:hover :first-child {
background: gray;
}
.box ul li:hover {
background: gray;
}
```
>## 方式二
**原理 :js控制元素隱藏顯示**
效果如圖:

> html代碼
```
<ul class="row">
<li><a href="#">電腦</a></li>
<li class="drop">
<a href="#" id="test">手機</a>
<div class="drop-content none" id="drop_content">
<a href="">小米</a>
<a href="">華為</a>
<a href="">蘋果</a>
</div>
</li>
<li><a href="#">平板</a></li>
</ul>
```
>css代碼
```
* {
margin: 0;
padding: 0;
}
ul {
line-height: 50px;
list-style: none;
}
.row::after {
content: "";
display: table;
clear: both;
}
li {
float: left;
text-align: center;
}
a {
display: inline-block;
width: 100px;
background-color: aqua;
text-decoration: none;
color: black;
}
a:hover {
background-color: cadetblue;
}
.drop {
position: relative;
}
.drop-content {
position: absolute;
}
.none{
display: none;
}
```
>javascript代碼
```
<script>
var test = document.getElementById("test");
var dropContent = document.getElementById("drop_content");
test.onclick = function(event){
dropContent.classList.toggle("none"); //移除掉class"none"
event.preventDefault();
}
</script>
```
- 空白目錄
- css實用樣式
- css--下拉欄的幾種設計
- css--圖片陰影以及浮起的效果
- css--圖片翻轉二:自動翻轉
- css--圖片翻轉一:滑過翻轉
- css--三種loading特效
- css--圖片遮罩效果實現
- css--又是三種loading特效
- css--帶三角形的圖形實現
- js demo
- 原生demo
- 1. 原生js實現輪播圖
- 2. 倒計時按鈕
- 3. 動態添加表格
- 4. checkbox全選反選
- 5. 小米登錄方式切換
- 6. 點擊事件
- 7. 個人網頁導航條(二)點擊滾動
- 8. 瀑布流實現!
- 9. 個人網頁導航條(一)滑動固定
- 10. 定時器實現淡入淡出效果
- 11. 輪播圖setTimeout版
- jQuery demo
- 1. 輪播圖實現!
- 2. 成都小風車導航特效
- html組件
- html--導航欄(家居醫生)
- html--登錄頁面(小米登錄)
- html--響應式導航條(木兮地板)
- html--搜索欄
- Vue demo
- 1. mvvm實現動態添加表格
- 2. 豆瓣TOP250渲染
- 3. 制作一段跑馬燈文字
- 3.1. vue 單行文字自動跑馬燈效果
- 4. 利用豆瓣接口搜索書籍
- 5. 制作簡易計算器
- 6. 創建一個點贊組件
- 7. 列表添加刪除動畫
- 8. isShow手風琴原理
- 9. tab欄切換