为了降低 服务器的接受和发送的请求次数,提示网站的加载速度所以要用精灵图
核心的属性:background-position
精灵图的坐标一般为 负值
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>精灵图</title>
<style>
div {
float: left;
background: url(image/abcd.jpg) no-repeat;
}
.l {
width: 93px;
height: 110px;
background-position: -7px -276px;
}
.i {
width: 62px;
height: 108px;
background-position: -326px -141px;
}
.a {
width: 107px;
height: 108px;
background-position: 0 -10px;
}
.o {
width: 108px;
height: 110px;
background-position: -373px -276px;
}
</style>
</head>
<body>
<div class="l"></div>
<div class="i"></div>
<div class="a"></div>
<div class="o"></div>
</body>
</html>
Image 10.png
网友评论