精靈圖使用技巧(86)

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

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章