Is there anyway to animate an ellipsis with CSS animations?

前端 未结 8 1070
情话喂你
情话喂你 2021-01-29 22:58

I\'m trying to have an ellipsis animate, and was wondering if it was possible with CSS animations...

So it might be like

Loading...
Loading..
Loading.
Lo         


        
8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-29 23:34

    You can animate clip (or better clip-path if you don't need IE support)

    div {
      position: relative;
      display: inline-block;
      font-size: 1.4rem;
    }
    
    div:after {
      position: absolute;
      margin-left: .1rem;
      content: ' ...';
      display: inline-block;
      animation: loading steps(4) 2s infinite;
      clip: rect(auto, 0px, auto, auto);
    }
    
    @keyframes loading {
      to {
        clip: rect(auto, 20px, auto, auto);
      }
    }
    Loading

提交回复
热议问题