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

猜你喜欢

转载自www.cnblogs.com/lwming/p/11730659.html