前端css知识实现自动打字,文字滚动


HTML部分:

    <div class="div1">
      <div class="div2">文字文字文字文字文字文字文字文字文字文字文字文字</div>
    </div>

CSS部分:

      .div1 {
        display: flex;
        justify-content: center;
        align-items: center;
      }
      .div2 {
        width: 300px;
        white-space: nowrap;
        overflow: hidden;
        border-right: 1px solid transparent;
        font-size: 16px;
        color: blue;
        animation: sizetype 5s steps(20) 0s backwards,
          showf 500ms steps(1) 0s 10 forwards;
        -webkit-animation: sizetype 5s steps(20) 0s backwards,
          showf 500ms steps(1) 0s 10 forwards;
      }
      @keyframes sizetype {
        from {
          width: 0;
        }
      }
      @keyframes showf {
        50% {
          border-right-color: currentColor;
        }
      }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM