Is there anyway to animate an ellipsis with CSS animations?

前端 未结 8 1052
情话喂你
情话喂你 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条回答
  •  生来不讨喜
    2021-01-29 23:09

    You could try to use the animation-delay property and time each ellipsis character. In this case I've put each ellipsis character in a so I can animate them separately.

    I made a demo, which isn't perfect, but it shows at least what I mean :)

    The code from my example:

    HTML

    Loading...

    CSS

    .one {
        opacity: 0;
        -webkit-animation: dot 1.3s infinite;
        -webkit-animation-delay: 0.0s;
        animation: dot 1.3s infinite;
        animation-delay: 0.0s;
    }
    
    .two {
        opacity: 0;
        -webkit-animation: dot 1.3s infinite;
        -webkit-animation-delay: 0.2s;
        animation: dot 1.3s infinite;
        animation-delay: 0.2s;
    }
    
    .three {
        opacity: 0;
        -webkit-animation: dot 1.3s infinite;
        -webkit-animation-delay: 0.3s;
        animation: dot 1.3s infinite;
        animation-delay: 0.3s;
    }
    
    @-webkit-keyframes dot {
        0% {
            opacity: 0;
        }
        50% {
            opacity: 0;
        }
        100% {
            opacity: 1;
        }
    }
    
    @keyframes dot {
        0% {
            opacity: 0;
        }
        50% {
            opacity: 0;
        }
        100% {
            opacity: 1;
        }
    }
    

提交回复
热议问题