liuyanxia

实现原理:变化前的图标和变化后的图标在一张图片上,用这张图片作为背景,通过定义背景的位置来实现显示哪个图标,其中还带着滑动的动画效果。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css">
    .wh{width: 17px;height: 13px;float:left;margin-right:5px;}
    .icon1{background: url(img/logo-sprite.png) no-repeat -1px -1px;transition: background 1s; }
    .icon2{background: url(img/logo-sprite.png) no-repeat -29px -1px;transition: background 1s;}
    .icon3{background: url(img/logo-sprite.png) no-repeat -59px -1px;transition: background 1s;}
    .icon1:hover{background: url(img/logo-sprite.png) no-repeat -1px -18px;}
    .icon2:hover{background: url(img/logo-sprite.png) no-repeat -29px -18px;}
    .icon3:hover{background: url(img/logo-sprite.png) no-repeat -59px -18px;}
    </style>
</head>
<body>
    <div class="contact">
        <div class="icon1 wh"></div>
        <div class="icon2 wh"></div>
        <div class="icon3 wh"></div>
    </div>
</body>
</html>

 

分类:

技术点:

相关文章:

  • 2022-02-11
  • 2021-09-07
  • 2022-12-23
  • 2022-12-23
  • 2022-03-01
  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-31
  • 2021-12-02
  • 2021-11-17
  • 2021-11-17
  • 2022-01-25
  • 2021-11-17
相关资源
相似解决方案