css 代码如何实现一个字节跳动的loading动画呢?


摘要:
下文讲述使用css代码实现一个字节跳动的Loading动画的方法说明,如下所示;

实现思路:  
    使用css animation定义不同的动画,模拟出loading动画

例:

 

<meta charset='utf-8' />
<p>
 maomao365.com <br />
css 实现一个字节跳动的loading动画的示例分享
</p>
<hr />

<div class="spinner">
    <div class="rect1"></div>
    <div class="rect2"></div>
    <div class="rect3"></div>
    <div class="rect4"></div>
    <div class="rect5"></div>
</div>

<style>
.spinner {
    width: 50px;
    height: 60px;
    text-align: center;
    font-size: 10px;
}
.spinner > div {
    background-color: green;
    height: 100%;
    width: 6px;
    display: inline-block;
    -webkit-animation: stretchdelay 1.2s infinite ease-in-out;
    animation: stretchdelay 1.2s infinite ease-in-out;
}
.spinner .rect2 {
    -webkit-animation-delay: -1.1s;
    animation-delay: -1.1s;
}
.spinner .rect3 {
    -webkit-animation-delay: -1.0s;
    animation-delay: -1.0s;
}
.spinner .rect4 {
    -webkit-animation-delay: -0.9s;
    animation-delay: -0.9s;
}
.spinner .rect5 {
    -webkit-animation-delay: -0.8s;
    animation-delay: -0.8s;
}
@-webkit-keyframes stretchdelay {
    0%, 40%, 100% { -webkit-transform: scaleY(0.4) } 
    20% { -webkit-transform: scaleY(1.0) }
}
@keyframes stretchdelay {
    0%, 40%, 100% {
    transform: scaleY(0.4);
    -webkit-transform: scaleY(0.4);
    } 20% {
    transform: scaleY(1.0);
    -webkit-transform: scaleY(1.0);
    }
}
</style>
css实现字节跳动动画的示例分享

css实现字节跳动动画的示例分享