弹跳加载器

创建一个弹跳加载器动画。

注意:1rem通常是16px

  1. @keyframes定义一个动画,具有两个状态,元素使用opacity改变透明度,使用transform: translate3d()在 2D 平面上平移。在transform: translate3d()上使用单轴平移可提高动画的性能。
  2. .bouncing-loader是弹跳圆的父容器,使用display: flexjustify-content: center将其放置在中心。
  3. .bouncing-loader > div,以要设置样式的父级的三个子div为目标。div给定宽度和高度1rem,使用border-radius: 50%从方形转成圆。
  4. margin: 3rem 0.2rem指定每个圆的上/下边距为3rem,左/右边距为0.2rem,使得它们不会彼此直接接触,给它们提供了一些间隔。
  5. animation是对于各种动画属性的简略属性:animation-nameanimation-durationanimation-iteration-countanimation-direction
  6. nth-child(n)定位为元素的第 n 个子元素。
  7. animation-delay分别在第二个和第三个div上使用,因此每个元素不会同时启动动画。
浏览器支持

100.0%

  • https://caniuse.com/#feat=css-animation
预览

可在 CodePen 中预览

HTML

<div class="bouncing-loader">
  <div></div>
  <div></div>
  <div></div>
</div>

CSS

@keyframes bouncing-loader {
  to {
    opacity: 0.1;
    transform: translate3d(0, -1rem, 0);
  }
}

.bouncing-loader {
  display: flex;
  justify-content: center;
}

.bouncing-loader > div {
  width: 1rem;
  height: 1rem;
  margin: 3rem 0.2rem;
  background: #8385aa;
  border-radius: 50%;
  animation: bouncing-loader 0.6s infinite alternate;
}

.bouncing-loader > div:nth-child(2) {
  animation-delay: 0.2s;
}

.bouncing-loader > div:nth-child(3) {
  animation-delay: 0.4s;
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值