CSS教程

css3 跑马灯

本文主要是介绍css3 跑马灯,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
@keyframes marqueeAnimation {
    0% {
        transform: translateX(100%);
    }
    100% {
        transform: translateX(-100%);
    }
}
.marquee-wrap{
    display: flex;
    background: #000;
    height: 50px;
    line-height: 50px;
    color: #fff;
    overflow: hidden;
}
.marquee-content{
    width: 100%;
    animation: marqueeAnimation 5s linear 0s infinite;
    overflow: hidden;
}

<section class="marquee-wrap">
    <section class="marquee-content">
        3232323323232332323233232323323232332323233232323323232332323233232323-----
    </section>
</section>

<script>
    let marqueeContent = document.getElementsByClassName('marquee-content')[0];
    marqueeContent.style.animationDuration =  3 * 0.2 + 10 + 's';
</script>
这篇关于css3 跑马灯的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!