js小动画

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>测试</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
    <style>
    .product-service-title {
        text-align: center;
        height: 146px;
        padding: 21px 0 19px;
        cursor: pointer;
    }

    .title-img {
        margin: 0 auto;
        width: 64px;
        height: 64px;
        background-repeat: no-repeat;
        background-position: 0 0;
        background-size: 100%;
        background-position-y: 0;
    }

    .title-desc {
        margin-top: 4px;
        text-align: center;
        font-size: 14px;
        color: #181818;
        line-height: 24px;
        font-weight: 400;
        margin-bottom: 0;
        transition: color .3s ease;
    }

   .title-content-underLine {
        transform: scaleX(0);
        transform-origin: 50% 50%;
        transition: transform .3s ease;
        width: 100%;
        margin: 11px auto 0;
        border-bottom: 3px solid #ff6a00;
    }

    .product-service-title:hover .title-desc{
        color:#ff6a00;
    }
    </style>
</head>

<body>

    <div id="app">
        <div class="product-service-title" ind="0" num_margin="0">
            <div class="title-img"
                style="background-image: url(&quot;https://img.alicdn.com/tfs/TB1cHirmP39YK4jSZPcXXXrUFXa-128-2688.png&quot;); background-position-y: 0px;">
                <!-- style="background-image: url(&quot;https://img.alicdn.com/tfs/TB111c4mz39YK4jSZPcXXXrUFXa-128-2688.png&quot;); background-position-y: 0px;"> -->
            </div>
            <h3 class="title-desc">网络与CDN</h3>
            <div class="title-content-underLine"></div>
        </div>
    </div>



    <script type="text/javascript">
        var aaa=bbb="";
        $('.title-img').mouseover(function () {
            clearInterval(bbb)
            var count=$(".title-img").css("background-position-y")
            var i=Number(count.substring(0,count.length-2));
            aaa=setInterval(() => {
                if(i>-1280){
                    i=i-64;
                    $(".title-img").css("background-position-y",i+"px");
                }else{
                    clearInterval(aaa)
                }
            }, 30);
        }).mouseout(function () {
            clearInterval(aaa)
            var count=$(".title-img").css("background-position-y")
            var i=Number(count.substring(0,count.length-2));
            bbb=setInterval(() => {
                if(i<0){
                    i=i+64;
                    $(".title-img").css("background-position-y",i+"px");
                }else{
                    clearInterval(bbb)
                }
            }, 30);
        })
    </script>
</body>

</html>

样式

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值