过渡效果实战2:当鼠标悬浮在图片上,图片背景转动产生类似于加载的效果

功能实现:

  • 当鼠标悬浮在图片上的时候,图片背景会转动起来

示例图片

在这里插入图片描述

代码:

<!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>过渡效果实战2</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        .box {
            width: 508px;
            height: 107px;
            border: 1px solid black;
            margin: 40px auto;
        }
        .box ul {
            list-style: none;
        }
        .box ul li {
            float: left;
            width: 107px;
            height: 107px;
            margin-right: 20px;
            position: relative;
        }
        /* 共性 */
        .box ul li::before {
            content: "";
            display: block;
            width: 107px;
            height: 107px;
            transform: rotate(0);
            transition: transform 1s ease 0s;
        }
        .box ul li:nth-child(1)::before {
            background-image: url(../images/a_1.png);
        }
        .box ul li:nth-child(2)::before {
            background-image: url(../images/a_2.png);
        }
        .box ul li:nth-child(3)::before {
            background-image: url(../images/a_3.png);
        }
        .box ul li:nth-child(4)::before {
            background-image: url(../images/a_4.png);
        }
        .box ul li img {
            position: absolute;
            width: 60px;
            height: 60px;
            margin-top: -85px;
            margin-left: 25px; 
            transition:transform 1s ease 0s ;
        }

        .box ul li:hover::before {
            transform: rotate(360deg);
        }
        .box ul li:hover img {
            transform: scale(1.2);
        }
    </style>
</head>
<body>
    <div class="box">
        <ul>
            <li><img src="../images/icon1.svg"></li>
            <li><img src="../images/icon2.svg"></li>
            <li><img src="../images/icon3.svg"></li>
            <li><img src="../images/icon4.svg"></li>
        </ul>
    </div>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值