摘要:<html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" cont
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>仿微信官网导航</title>
</head>
<style>
* {
margin: 0;
padding: 0;
}
body {
font-family: Microsoft YaHei;
}
ol,
ul,
li {
list-style: none;
box-sizing: border-box;
}
a {
text-decoration: none;
}
.wrap {
background: url(https://res.wx.qq.com/a/wx_fed/weixin_portal/res/static/img/3S9sFMD.jpg) repeat-x center top;
}
.top {
position: relative;
width: 968px;
height: 75px;
margin: 0 auto;
}
.logo {
position: absolute;
height: 44px;
top: 14px;
left: 0;
}
.nav {
float: right;
padding-top: 21px;
}
.nav li {
float: left;
background-size: auto 100%;
}
.nav li a {
display: block;
padding-left: 16px;
line-height: 33px;
margin: 0 2px;
}
.nav-home a{
background: url(https://res.wx.qq.com/a/wx_fed/weixin_portal/res/static/img/lTcb_ve.png) no-repeat left;
}
.nav-home span {
font-weight: bold;
background: url(https://res.wx.qq.com/a/wx_fed/weixin_portal/res/static/img/lTcb_ve.png) no-repeat right;
}
.nav-other:hover a {
background: url(https://res.wx.qq.com/a/wx_fed/weixin_portal/res/static/img/3w4CwHw.png) no-repeat left;
}
.nav-other:hover span {
background: url(https://res.wx.qq.com/a/wx_fed/weixin_portal/res/static/img/3w4CwHw.png) no-repeat right;
}
.nav-home span,
.nav-other span {
display: block;
font-size: 14px;
color: #fff;
padding-right: 16px;
cursor: pointer;
}
</style>
<body>
<div class="wrap">
<div class="top">
<a href="/"><img class="logo" src="https://res.wx.qq.com/a/wx_fed/weixin_portal/res/static/img/dNEBuK6.png"></a>
<ul class="nav">
<li class="nav-home">
<a href="/"><span>首页</span></a>
</li>
<li class="nav-other">
<a href=""><span>帮助与反馈</span></a>
</li>
<li class="nav-other">
<a href=""><span>公众平台</span></a>
</li>
<li class="nav-other">
<a href=""><span>开放平台</span></a>
</li>
<li class="nav-other">
<a href=""><span>微信支付</span></a>
</li>
<li class="nav-other">
<a href=""><span>微信网页版</span></a>
</li>
<li class="nav-other">
<a href=""><span>表情开放平台</span></a>
</li>
<li class="nav-other">
<a href=""><span>微信广告</span></a>
</li>
</ul>
</div>
</div>
</body>
</html>
总结:margin-top少用,尽可能用padding-top或者定位,模仿数值不能错。
批改老师:天蓬老师批改时间:2019-02-20 14:50:58
老师总结:padding和margin用途不同, 该用哪用哪个, 不必纠结