zoukankan      html  css  js  c++  java
  • 纯css3制作无限循环横向滚动的文字广告动画

    <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>使用css3制作文字横向无限循环滚动的动画</title>
        <style>
      /**
          设置宽,溢出隐藏
      */
            .marquee-outer-wrapper{
                overflow: hidden;
                 80%;
            }
            .marquee-inner-wrapper{
                background: #eee;
                height: 40px;
                font-size: 14px;
                color: red;
                line-height: 40px;
                margin: 0 auto;
                white-space: nowrap;
                position: relative;
            }
      /* 需要将两个文字内容一样的span放在最右边 */
            .marquee-inner-wrapper span{
                position: absolute;
                top: 0;
                left: 100%;
                height: 100%;
            }
      /* 定义第一个span的animation:时长 动画名字 匀速 循环 正常播放 */
            .first-marquee{
                -webkit-animation: 25s first-marquee linear infinite normal;
                animation: 25s first-marquee linear infinite normal;
                padding-right: 70%;
            }
            @keyframes first-marquee {
                0% {
                    -webkit-transform: translate3d(0, 0, 0);
                    transform: translate3d(0, 0, 0);
                }
         /* 向左移动 */
                100% {
                    -webkit-transform: translate3d(-200%, 0, 0);
                    transform: translate3d(-200%, 0, 0);
                    display: none;
                }
            }
            .second-marquee{
        /* 因为要在第一个span播完之前就得出现第二个span,所以就延迟12s才播放 */
                -webkit-animation: 25s first-marquee linear 12s infinite normal;
                animation: 25s first-marquee linear 12s infinite normal;
                padding-right: 53%;
            }
            @keyframes second-marquee {
                0% {
                    -webkit-transform: translate3d(0%, 0, 0);
                    transform: translate3d(0%, 0, 0);
                }
                100% {
                    -webkit-transform: translate3d(-200%, 0, 0);
                    transform: translate3d(-200%, 0, 0);
                    display: none;
                }
            }
        </style>
    </head>
    <body>
        <div class="marquee-outer-wrapper">
            <div class="marquee-inner-wrapper">
                <span class="first-marquee">使用css3制作文字横向无限循环滚动的动画使用css3制作文字横向无限循环滚动的动画使用css3制作文字横向无限循环滚动的动画</span>
                <span class="second-marquee">使用css3制作文字横向无限循环滚动的动画使用css3制作文字横向无限循环滚动的动画使用css3制作文字横向无限循环滚动的动画</span>
            </div>
        </div>
    </body>
    </html>
  • 相关阅读:
    竞品选择的背后
    小程序UI
    效果CSS实现三角
    pmp心得
    [已读]响应式web设计实践
    [在读]HTML5程序设计(第二版)
    [已读]响应式web设计
    [已读]HTML5与CSS3权威指南第二版(下)
    [已读]编写可维护的javascript
    [未读]JavaScript高效图形编程
  • 原文地址:https://www.cnblogs.com/duanjiujiu/p/9317536.html
Copyright © 2011-2022 走看看