前端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