使用css animation对两段文字添加上下无效滚动效果

复制代码
<div className={style.invite}>
    <img src={inviteIcon} />
    <div className={style.invite_content_box}>
        <div className={`${style.invite_content_box_list}`}>
            <div className={`${style.item} ${style.item_1}`} onClick={handleJumpInvite}>
                邀请好友注册,享 <span>50</span> 条消息数
            </div>
            <div className={`${style.item} ${style.item_2}`}>新注册用户,免费体验三天</div>
            <div className={`${style.item} ${style.item_3}`} onClick={handleJumpInvite}>
                邀请好友注册,享 <span>50</span> 条消息数
            </div>
        </div>
    </div>
</div>



.invite {
    background: rgba(236, 7, 135, 0.30);
    height: 32px;
    line-height: 32px;
    overflow: hidden;
    margin-top: 12px;
    border-radius: 16px;

    > img {
        margin-right: 4px;
        margin-left: 8px;
    }

    .invite_content_box {
        margin-top: 48px;
        width: 208px;

        .invite_content_box_list {
            height: 72px;
            position: relative;
            animation: moreContentScroll 6s ease-out infinite;
            animation-delay: 2s;

            .item {
                position: absolute;
                width: 100%;
                height: 24px;
                line-height: 24px;

                color: #FFF;
                font-size: 14px;
                font-style: normal;
                font-weight: 400;
            }

            .item_1 {
                top: 0;
            }

            .item_2 {
                top: 24px;
            }

            .item_3 {
                top: 48px;
            }
        }
    }
}


@keyframes moreContentScroll{
    0% {
        transform: translateY(0);
    }
    5% {
        transform: translateY(-24px);
    }
    50% {
        transform: translateY(-24px);
    }
    55% {
        transform: translateY(-48px);
    }
    100% {
        transform: translateY(-48px);
    }
}

参考如下网址

c摄图网-正版高清图片免费下载_商用设计素材图库

相关推荐
NiceCloud喜云5 小时前
Opus 4.8 的 Effort Control 怎么选:Low 到 Max 五档策略
android·java·大数据·前端·c++·python·spring
wordbaby5 小时前
React Native + RNOH:跨页面数据回传的最佳实践与避坑指南
前端·react native
GISer_Jing5 小时前
Three.js着色器编译机制深度解析
javascript·webgl·着色器
丷丩5 小时前
MapLibre GL JS第22课:查看本地GeoJSON
前端·javascript·map·mapbox·maplibre gl js
油炸自行车5 小时前
Claude Code 错误:API Error: 400 Failed to deserialize the JSON body into the
开发语言·javascript·json·trae·claude code·api error 400
Front思6 小时前
AI前端工程师需要具备能力+
前端·人工智能·ai
ZC跨境爬虫8 小时前
跟着 MDN 学CSS day_29:(掌握文本与字体样式的核心艺术)
前端·css·ui·html·tensorflow
李子琪。9 小时前
网络空间安全深度实战:CSRF 漏洞原理剖析与基于 Token 的纵深防御体系构建(全栈实验报告)
前端·安全·csrf
冰暮流星9 小时前
javascript之history对象介绍
前端·笔记
IT_陈寒9 小时前
Vite热更新失灵?你可能漏了这个配置
前端·人工智能·后端