2019-3-2 网页设计-菜单背景定位和反转
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<style type="text/css">
ul {
list-style-type: none;
}
li {
height: 58px;
width: 160px;
float: left;
}
a {
display: block;
height: 100%;
width: 100%;
line-height: 500px;
overflow: hidden;
background-image: url(Pic/menu.gif);
background-repeat: no-repeat;
}
a.bg1{
background-position: 0 0;
}
a.bg2{
background-position: 0 -70px;
}
a.bg3{
background-position: 0 -140px;
}
a.bg4{
background-position: 0 -210px;
}
a:hover.bg1{
background-position: -170px 0;
}
a:hover.bg2{
background-position: -170px -70px;
}
a:hover.bg3{
background-position: -170px -140px;
}
a:hover.bg4{
background-position: -170px -210px;
}
</style>
</head>
<body>
<ul>
<li><a class="bg1" href="#">美容健康</a></li>
<li><a class="bg2" href="#">乐活情爱</a></li>
<li><a class="bg3" href="#">原创专题</a></li>
<li><a class="bg4" href="#">自媒体</a></li>
</ul>
</body>
</html>
图片素材下载: