css下拉菜单的学习

原创 2018-11-05 21:28:13 203
摘要:<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>淘宝导航</title> <link rel="stylesheet" type="text/css&qu
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>淘宝导航</title>
	<link rel="stylesheet" type="text/css" href="css/index.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_conter">
		<div class="header_left">
			<a href="" class="header_a" style="color: #3c3c3c">中国大陆&nbsp; <i class=" fa fa-angle-down
"></i></a>
			<a href="" style="color: #f22e00">亲,请登录</a>
			<a href="" class="header_b" style="margin-left: -10px">免费注册</a>
			<a href="" class="header_b" >手机逛淘宝</a>
		</div>
		<div class="header_right">
			<a href="" class="header_a">我的淘宝&nbsp;&nbsp;<i class="fa fa-angle-down"></i>
				<ul>
					<li>已买到的宝贝</li>
					<li>我的足迹</li>
				</ul>
			</a>
			<a href="" class="header_a"> <span class="fa fa-shopping-cart" style="color: #f22e00"></span>&nbsp;购物车&nbsp;&nbsp;<i class="fa fa-angle-down"></i>
			</a>
			<a href="" class="header_a"> <span class="fa fa-star"></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;&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;&nbsp;<i class="fa fa-angle-down"></i>
				<ul>
					<li>消费者客服</li>
					<li>卖家客服</li>
				</ul>
			</a>
			<a href="" class="header_c"> <span class="fa fa-navicon" style="color: #f22e00"></span>&nbsp;&nbsp;网站导航&nbsp;&nbsp;<i class="fa fa-angle-down"></i>
				<ul>
					<li style="color: #fc4200">主题市场</li>
					<li style="color: #d4ca38">特色市场</li>
					<li style="color: #d75696">阿里APP</li>
					<li style="color: #2e9fdb">精彩推荐集</li>
				</ul>
				<div class="clear"></div>
			</a>
		</div>
	</div>
	<div class="clear"></div>
</div>
</body>
</html>

css名称index.css

*{margin: 0px;padding: 0px;}
a{text-decoration: none;color: #6c6c6c;font-size: 15px;}
li{list-style: none;}
.clear{clear: both;}
.header{width: 100%;background-color: #f5f5f5;}
.header_conter{width: 1488px;margin: 0px auto;line-height: 40px;}
.header_left{height: 40px;float: left;}
.header_left a{margin-right: 15px;}
.header_b:hover{color: #f22e00; }
.header_right a:hover{color: #f22e00;}
.header_right{width: 740px;height: 40px;float: right;}
.header_right a{margin-right: 20px;}
.header_a{display: inline-block;height: 40px;width: auto;text-align: center;position: relative;}
.header_a:hover{background: #fff;}
.fa-angle-down{color: #6c6c6c;}
.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{color: #6c6c6c;height: 30px;line-height: 30px;text-align: left;padding: 0px 5px;margin: 5px 0px;}
.header_a ul li:hover{background-color: #f5f5f5;}
.header_c{display: inline-block;position: relative;}
.header_c:hover{background: #fff;}
.header_c ul{width: 1488px;height: 385px;background: #fff;border: 1px solid #f5f5f5;display: none;border-top: none;}
.header_c:hover ul{display: block;position: absolute;right: 0px;}
.header_c ul li{float: left;padding: 10px;margin-right: 260px;font-size: 20px;}

这节课的学习使我对以前的知识得到深刻的回顾和理解,清晰的了解到了css下拉菜单效果的设置,目前对于每个元素之间的距离设置不大会计算,相信通过以后的学习会更加清晰。

hover的用法:冒号前面为鼠标放置对象hover后面为显示对象。

批改老师:天蓬老师批改时间:2018-11-05 21:45:09
老师总结:代码逻辑是正确的,下次提交这类代码,应该将他们放在正确的标签中一并提交

发布手记

热门词条