abstract:<!DOCTYPE html> <html> <head> <title>html+css实战布局</title> <link rel="stylesheet" type="text/css" href="style.css"&g
<!DOCTYPE html> <html> <head> <title>html+css实战布局</title> <link rel="stylesheet" type="text/css" href="style.css"> <link rel="stylesheet" type="text/css" href="css/font-awesome-4.7.0/css/font-awesome.min.css"> </head> <body> <div class="header"> <div class="header-content"> <div class="header-left"> <a href="" class="header-a">中国大陆 <i class="fa fa-angle-down"></i></a> <a href="" style="color:#FF5000">亲,请先登录<i class="fa fa-angle-down"></i></a> <a href="" class="header-a">免费注册<i class="fa fa-angle-down"></i></a> <a href="" class="header-a">手机淘宝<i class="fa fa-angle-down"></i></a> </div> <div class="header-right"> <a href="" class="header-a">我的淘宝<i class="fa fa-angle-down"></i> <ul> <li>已买到的宝贝</li> <li>我的足迹</li> </ul> </a> <a href=""><span class="fa fa-cart-plus" style="color:#FF5000"></span> 购物车</a> <a href="" class="header-a">收藏夹<i class="fa fa-angle-down"></i></a> <a href=""><span class="fa fa-star"></span>商品分类</a> <a href="" class="header-a">卖家中心<i class="fa fa-angle-down"></i></a> <a href="" class="header-a">联系客服<i class="fa fa-angle-down"></i></a> <a href="" class="header-a">网站导航<i class="fa fa-angle-down"></i></a> </div> </div> <div class="clear"></div> </div> </body> </html>
style.css
*{margin:0px;padding:0px;}
a{text-decoration: none;color:#000;font-size: 13px;}
.clear{clear:both;}
.header{width: 100%;background-color: #F5F5F5;}
.header-content{width: 1200px;margin:0px auto;line-height: 40px;}
.header-content a:hover{color:#FF5000;}
.header-left{height:40px;float: left;}
.header-left a{margin-right: 5px;}
.header-right{width: 700px;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{list-style:none;border: 1px solid #F5F5F5;display: none;border-top: none;}
.header-a:hover ul{display: block;position: absolute;width: 100%;}
.header-a ul li{color: #6c6c6c;height: 30px;line-height: 30px;text-align: left;padding-right: 0px 3px;margin: 5px 0px;}
.header-a ul li:hover{background-color: #ccc;}
在布局的过程中使用过浮动后要记得清除浮动,多列表定位要弄清楚定位的方式(父级相对定位,子级绝对定位),内边距和外边距等细节性的地方也不容忽视
Correcting teacher:西门大官人Correction time:2019-03-03 09:51:18
Teacher's summary:下拉菜单的核心思想是子菜单的显示和隐藏,通过css的hover来实现