<!DOCTYPE html>
<html lang="ch">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- 引入重置样式 -->
<link rel="stylesheet" href="./css/reset.css">
<!-- 引入图标样式 -->
<link rel="stylesheet" href="./fontawesome/css/all.css">
<title>导航条练习</title>
<style>
/* 设置整体页面字体 */
body {
font-size: 12px;
font-family: sans-serif;
background-color: rgba(24, 20, 20, 0.932);
}
/* 设置外部容器样式 */
.top-bar-wrapper {
width: 100%;
background-color: rgb(227,228,229);
line-height: 30px;
border-bottom: 1px solid #ddd;
}
/* 设置内部容器样式 */
.top-bar {
margin: 0 auto;
width: 1190px;
line-height: 30px;
}
/* 设置字体样式 */
.top-bar a:hover {
color: rgb(241,2,21);
}
.top-bar a,
.top-bar li {
text-decoration: none;
color: rgb(153,153,153);
}
.shortcut .hightlight {
color:rgb(241,2,21);
}
/* 设置字体浮动 */
.shortcut {
float: right;
}
.shortcut li {
float: left;
}
.location {
float: left;
}
/* 设置定位图标样式 */
.fa-map-marker-alt {
color: rgb(241,2,21);
font-size: 13px;
}
/* clearfix,解决高度塌陷 */
.clearfix::before,
.clearfix::after {
content: '';
display: table;
clear: both;
}
/* 设置分割线样式 */
.line {
width: 1px;
height: 10px;
background-color: rgb(153,153,153);
margin: 10px 12px;
}
/* 做下拉框 */
/* 鼠标移入location就出现下拉框 */
.location:hover .map-list {
display: block;
}
.current-city {
line-height: 29px;
padding: 0 6px;
position: relative;
}
/* 鼠标移入location就变白色 */
.location:hover
.current-city {
background-color: white;
border: 1px solid rgb(204,204,204);
border-bottom: none;
}
/* 鼠标移入location就用伪元素用来遮盖用的 */
.location:hover
.current-city::after {
content: '';
display: block;
width: 100%;
height: 1px;
position: absolute;
left: -1px;
z-index: 999;
background-color: white;
border-left: 1px solid rgb(204,204,204);
border-right: 1px solid rgb(204,204,204);
}
.map-list {
display: none;
width: 402px;
height: 580px;
background-color: white;
border: 1px solid rgb(204,204,204);
/* 脱离文档流 */
position: absolute;
}
</style>
</head>
<body>
<!-- 创建外围容器 -->
<div class="top-bar-wrapper">
<!-- 创建内部容器 -->
<div class="top-bar clearfix">
<!-- 左侧的菜单 -->
<div class="location">
<div class="current-city">
<i class="fa fa-map-marker-alt"></i>
<a href="javascript:;">北京</a>
</div>
<div class="map-list"></div>
</div>
<!-- 右侧的菜单 -->
<ul class="shortcut">
<li>
<a href="javascript:;">你好,请登录</a>
<a href="javascript:;" class="hightlight">免费注册</a>
</li>
<!-- 分割线 -->
<li class="line"></li>
<li><a href="javascript:;">我的订单</a></li>
<li class="line"></li>
<li>
<a href="javascript:;">我的京东</a>
<i class="fa fa-angle-down"></i>
</li>
<li class="line"></li>
<li><a href="javascript:;">京东会员</a></li>
<li class="line"></li>
<li><a href="javascript:;" class="hightlight">企业采购</a></li>
<li class="line"></li>
<li>
<span>客户服务</span>
<i class="fa fa-angle-down"></i>
</li>
<li class="line"></li>
<li>
<span>网站导航</span>
<i class="fa fa-angle-down"></i>
</li>
<li class="line"></li>
<li>
<span>手机京东</span>
</li>
</ul>
</div>
</div>
</body>
</html>
67导航条练习
最新推荐文章于 2022-04-11 20:24:39 发布