淘宝导航下拉菜单的案例总结

原创 2018-11-02 22:39:49 243
摘要:html代码<!DOCTYPE html> <head> <meta charset="UTF-8"> <title>淘宝</title> <link rel="stylesheet" type="text/css" 

html代码

<!DOCTYPE html>
<head>
	<meta charset="UTF-8">
	<title>淘宝</title>
	<link rel="stylesheet" type="text/css" href="css/index.css">
	<link rel="stylesheet" href="css/font-awesome/css/font-awesome.min.css">		

</head>
<body>
	<div class="header">
		<div class="header_content">
		<!-- 左边导航 -->
		<div class="content-left">
		<a href="" class="header_a">中国大陆&nbsp;&nbsp;<i class="fa fa-angle-down"></i></a> 
		<!-- 一些小间距可以用&nbsp实现,小图标可以采用引用字体库 -->
		<a href="" style="color:#FF5000;">亲,请登录</a>
		<a href="">免费注册</a>
		<a href="">手机淘宝</a>
		</div>
		<!-- 右边导航 -->
		<div class="content-right">
			<a href="" class="header_a">我的淘宝&nbsp;<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>&nbsp;购物车
				
			 </a>
			<a href="" class="header_a"><span class="fa fa-star" style="color:#FF5000;"></span>&nbsp;收藏夹&nbsp;<i class="fa fa-angle-down"></i>
				<ul>
					<li>收藏的宝贝</li>
					<li>收藏的店铺</li>
				</ul>
			 </a>
			<a href="">商品分类</a>
			<a href="" class="header_a">卖家中心&nbsp;<i class="fa fa-angle-down"></i>
				<ul>
					<li>免费开店</li>
					<li>已卖出的宝贝</li>
					<li>出售中的宝贝</li>
					<li>卖家服务市场</li>
					<li>卖家培训中心</li>
					<li>体验中心</li>
					<li>问商友</li>
				</ul>
			 </a>
			<a href="" class="header_a">联系客服&nbsp;<i class="fa fa-angle-down"></i>
				<ul>
					<li>消费者客服</li>
					<li>卖家客服</li>
				</ul>
			 </a>
			<a href="" class="header_a"><span class="fa fa-align-justify" style="color:#FF5000;"></span>&nbsp;网站导航&nbsp;<i class="fa fa-angle-down"></i>
				<ul>
					<li>已买到的宝贝</li>
					<li>我的足迹</li>
				</ul>
			 </a>
		</div>
		</div>
		<div class="clear"></div><!-- 要导航引起的清除浮动 -->
	</div>
</body>
</html>

css代码:

*{margin: 0px;padding: 0px;}/*对网页初始化,去除内外边距*/
.clear{clear: both;}
li{list-style: none;}
a{text-decoration: none;color: #6c6c6c;font-size: 13px;}/*去除a的样式*/
.header{ width: 100%;height:40px; background-color:#F5F5F5;}
.header_content{width: 1200px;height: 40px;margin:0px auto;}
.content-left{height: 40px;float:left;line-height: 40px;}
.content-left a{margin-right: 5px;}
.content-right{height: 40px;float:right;line-height: 40px;}
.header_a{display: inline-block;height: 40px;width:85px;text-align: center;position: relative;}
.header_content a:hover{color: #FF5000;}
.header_a:hover{background: #fff;}
.header_a ul{border: 1px solid #F5F5F5;display:none;position:absolute;border-top: none; }/*display:none在鼠标未覆上时隐藏;通过position:absolute和上面的父级a标签的position: relative使导航不发生位移。*/
.header_a:hover ul{display: block;width: 100px;}/*设置下拉框的大小*/
.header_a ul li:hover { background-color:#F5F5F5;padding:0px 3px;}/*鼠标覆上时li元素的背景色改变*/
.header_a ul li{color: #6c6c6c;height: 30px;line-height: 30px;text-align:left;margin:5px 0px; }


批改老师:韦小宝批改时间:2018-11-03 09:13:52
老师总结:写的很完整啊!赞一哈!下次记得加点总结和多点注释哈!继续加油吧~~

发布手记

热门词条