css 动画 loading(一)

html:

<div class="wrap">
    <div class="round"></div>
    <div class="round"></div>
    <div class="round"></div>
    <div class="round"></div>
    <div class="round"></div>
    <div class="round"></div>
</div>

 less

@ballConSize: 100px;
@littleBallConSize: 16px;
.wrap {
  box-sizing: border-box;
  width: @ballConSize;
  height: @ballConSize;
  margin-top: 150px;
  margin-left: 150px;
  position: relative;
  border-radius: 50%;

  .round {
    border-radius: 50%;
    position: absolute;
    top: (@ballConSize/2);
    left: (@ballConSize/2);
  }
}
@keyframes loadingAni {
  0%{
    transform: rotate(0deg) translateY(-(@ballConSize/2));
    transition-timing-function: ease-in;
  }
  100%{
    transform: rotate(360deg) translateY(-(@ballConSize/2));
    transition-timing-function: ease-in;
  }
}

.loop(@i) when (@i <= 6) {
  .round:nth-child(@{i}) {
    width: @littleBallConSize * (0.4 + @i * 0.1);
    height: @littleBallConSize * (0.4 + @i * 0.1);
    margin-left: -(@littleBallConSize * (0.4 + @i * 0.1)/2);
    margin-top: -(@littleBallConSize * (0.4 + @i * 0.1)/2);
    background: rgb(199, 136, 185);
    transform: translateY(-(@ballConSize/2));
    animation: loadingAni 2s infinite;
    animation-delay: -(0.1s * @i);
  }
  .loop(@i + 1)
}
.loop(1);

less转换后的CSS:

.wrap {
  box-sizing: border-box;
  width: 100px;
  height: 100px;
  margin-top: 150px;
  margin-left: 150px;
  position: relative;
  border-radius: 50%;
}
.wrap .round {
  border-radius: 50%;
  position: absolute;
  top: 50px;
  left: 50px;
}
@keyframes loadingAni {
  0% {
    transform: rotate(0deg) translateY(-50px);
    transition-timing-function: ease-in;
  }
  100% {
    transform: rotate(360deg) translateY(-50px);
    transition-timing-function: ease-in;
  }
}
.round:nth-child(1) {
  width: 8px;
  height: 8px;
  margin-left: -4px;
  margin-top: -4px;
  background: #c788b9;
  transform: translateY(-50px);
  animation: loadingAni 2s infinite;
  animation-delay: -0.1s;
}
.round:nth-child(2) {
  width: 9.6px;
  height: 9.6px;
  margin-left: -4.8px;
  margin-top: -4.8px;
  background: #c788b9;
  transform: translateY(-50px);
  animation: loadingAni 2s infinite;
  animation-delay: -0.2s;
}
.round:nth-child(3) {
  width: 11.2px;
  height: 11.2px;
  margin-left: -5.6px;
  margin-top: -5.6px;
  background: #c788b9;
  transform: translateY(-50px);
  animation: loadingAni 2s infinite;
  animation-delay: -0.3s;
}
.round:nth-child(4) {
  width: 12.8px;
  height: 12.8px;
  margin-left: -6.4px;
  margin-top: -6.4px;
  background: #c788b9;
  transform: translateY(-50px);
  animation: loadingAni 2s infinite;
  animation-delay: -0.4s;
}
.round:nth-child(5) {
  width: 14.4px;
  height: 14.4px;
  margin-left: -7.2px;
  margin-top: -7.2px;
  background: #c788b9;
  transform: translateY(-50px);
  animation: loadingAni 2s infinite;
  animation-delay: -0.5s;
}
.round:nth-child(6) {
  width: 16px;
  height: 16px;
  margin-left: -8px;
  margin-top: -8px;
  background: #c788b9;
  transform: translateY(-50px);
  animation: loadingAni 2s infinite;
  animation-delay: -0.6s;
}
/*# sourceMappingURL=loading5dot.css.map */

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值