这是一张精灵图集合图,一般叫做sprites或者精灵雪碧
利用背景精灵图的位置来进行测算。因为默认的背景图 是靠在最右上角的,所以呢,只有移动背景图片才能可以实现这个功能。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box{
height: 60px;
width: 60px;
margin: 100px auto;
background: url(../imgs/sprites.png);
background-position: -182px 0px;
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>