下拉菜单案例和总结

Original 2018-11-03 10:53:12 221
abstract:*{margin: 0px;padding: 0px;} a{text-decoration: none;color: #6c6c6c;font-size: 13px;} li{list-style: none;} .clear{clear: both;} .header{width: 100%;background-
*{margin: 0px;padding: 0px;}
a{text-decoration: none;color: #6c6c6c;font-size: 13px;}
li{list-style: none;}
.clear{clear: both;}
.header{width: 100%;background-color:#f5f5f5;}
.header_content{width:1200px;margin: 0px auto;line-height: 40px}
.header_left{width: 300px;height: 40px;float: left;}
.header_left a{margin-right: 5px;}
.header_content a:hover{color: #FF5000;}
.header_right{width: 600px;height: 40px;float: right;}
.header_a{display: inline-block;height: 40px;width: 90px;text-align: center;position: relative;}
.header_a:hover{background-color: #fff;}
.header_a ul{border:1px solid #F5F5F5; display: none;border-top: none;}
.header_a:hover ul{display: block;position: absolute;width: 100px;}
.header_a ul li:hover{background-color: #F5F5F5;}
.header_a ul li{color: #6c6c6c;height: 30px;line-height: 30px;text-align: left;padding:0px 5px;margin:5px 0px;}

导航是通过a标签来撰写的,下拉列表是通过ul无序列表来写的,通过display:none来隐藏,结合hover伪类和display:block来完成鼠标在元素上显示下拉列表效果。通过元素选择器和选择器,给导航添加样式,relative是相对定位,定位对象是自身,absolute是绝对定位,定位对象是其有定位的父级元素。

Correcting teacher:灭绝师太Correction time:2018-11-03 11:46:37
Teacher's summary:后面的课程会更精彩,保留写总结的习惯。代码中也要习惯加备注

Release Notes

Popular Entries