這是一張精靈圖集合圖,一般叫做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>