竖向文字 js 无缝滚动

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>无缝滚动</title>
    <style>
        body,
        #app {
            margin: 0;
            padding: 0;
            font-family: Helvetica;
            background: #f0efef !important;
            width: 100%;
            overflow-x: hidden;
        }
        
        a {
            text-decoration: none;
        }
        
        .pro_quota_tip {
            background: #fff;
            font-size: 14px;
            overflow: hidden;
            width: 200px;
            height: 49px;
            margin: 0 auto;
            margin-top: 10%
        }
        
        .pro_quota_tip .tip_box {
            position: relative;
        }
        
        .pro_quota_tip .tip_box a {
            color: red;
            display: block;
            width: 100%;
            padding: 15px 5px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
    </style>
</head>

<body>
    <section class="pro_quota_tip">
        <div class="tip_box">
            <a href="javascript:;">aaaaaaaaa</a>
            <a href="javascript:;">bbbbbbbbbbbbbb</a>
            <a href="javascript:;">ccccccccccc</a>
            <a href="javascript:;">ddddddddddddddd</a>
            <a href="javascript:;">aaaaaaaaaaaaaa</a>
        </div>
    </section>
</body>
<script>
    var tip_box_a_h = document.querySelectorAll('.tip_box a')[0].offsetHeight;
    var i = 0;
    setInterval(() => {
        let startScroll = setInterval(() => {
            i++;
            document.querySelector('.tip_box').style.bottom = (tip_box_a_h / 10) * i + 'px';
            if (i % 10 == 0) clearInterval(startScroll);
        }, 50)
        if (i > (10 * (document.querySelectorAll('.tip_box a').length - 2))) i = 0;
    }, 2500)
</script>

</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值