0
点赞
收藏
分享

微信扫一扫

精灵图使用方法

柠檬果然酸 2022-04-16 阅读 121
前端

精灵图使用步骤:

  • 第一步:先测量精灵图局部的大小,设置为盒子的宽和高
  • 第二步:测量精灵图局部的坐标值,设置为背景定位的负值
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            width: 20px;
            height: 20px;
            background: #000 url(./img/微信图片_20220402111135.png) no-repeat -34px -4px;
        }
        .box1 {
            width: 20px;
            height: 20px;
            margin-top: 20px;
            border: 1px solid #000;
            background: #333 url(./img/微信图片_20220402111135.png) no-repeat -94px -6px;
        }
    </style>
</head>
<body>
    <div class="box"></div>
    <div class="box1"></div>
</body>
</html>
举报

相关推荐

0 条评论