<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
.box{
width: 43px;
height: 42px;
background: url(../img/logo.jpg) no-repeat -46px -47px;
}
/* .box:hover{
width: 43px;
height: 42px;
background: url(../img/logo.jpg) no-repeat -46px -2px;
} */
.box1{
width: 44px;
height: 44px;
background: url(../img/logo.jpg) no-repeat;
}
/* .box1:hover{
width: 44px;
height: 44px;
background: url(../img/logo.jpg) no-repeat 0 -45px;
} */
.box2{
width: 44px;
height: 44px;
background: url(../img/logo.jpg) no-repeat -90px 0;
}
/* .box2:hover{
width: 44px;
height: 44px;
background: url(../img/logo.jpg) no-repeat -90px -45px;
} */
</style>
</head>
<body>
<div class="box">
</div>
<div class="box1">
</div>
<div class="box2">
</div>
</body>
</html>
优点:css 精灵图,把一堆小的图片整合到一张大的图片(png)上,减轻服务器对图片的请求数量。
position: relative; 可以定位到自己想要的位置 要记得和position: absolute;配合 使用
加入hover 可以使背景图进行 山东效果
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
div ul li{
list-style: none;
background: url(./img/sqpurple.gif)no-repeat left center;
padding-left: 15px;
line-height: 25px;
}
</style>
</head>
<body>
<div>
<ul>
<li>这是一个li标签</li>
<li>这是一个li标签</li>
<li>这是一个li标签</li>
</ul>
</div>
</body>
</html>
使用精灵图 更换li 标签前面的 小圆点