css实现多个loading动画效果

效果展示

在开发中,为了提高用户体验,通常在加载数据的时候会给一个loading提示,这里分享几个简单的loading加载效果
根据序号查看代码,尾部有整合代码Gitee链接

loading

01

<div class="loading"></div>
.loading {
  width: 30px;
  height: 30px;
  border: 2px solid #1890ff;
  border-top-color: transparent;
  border-radius: 50%;
  animation: rotate 0.75s linear infinite;
}

@keyframes rotate {
  to {
    transform: rotate(360deg);
  }
}

02

<div class="loading"></div>
.loading {
  width: 30px;
  height: 30px;
  border: 2px solid #1890ff;
  border-bottom: 2px solid rgba(24, 144, 255, 0.2);
  border-left: 2px solid rgba(24, 144, 255, 0.2);
  border-right: 2px solid rgba(24, 144, 255, 0.2);
  border-radius: 50%;
  animation: rotate 0.75s linear infinite;
}

@keyframes rotate {
  to {
    transform: rotate(360deg);
  }
}

03

<div class="loading">
      <div></div>
      <div></div>
      <div></div>
</div>
.loading {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  justify-items: center;
  column-gap: 8px;
}

.loading div {
  width: 10px;
  height: 10px;
  background-color: #1890ff;
  border-radius: 50%;
  animation: jump 0.6s alternate infinite;
}

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

.loading div:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes jump {
  to {
    opacity: 0.1;
    transform: translateY(-16px);
  }
}

04

<div class="loading">
      <div></div>
      <div></div>
      <div></div>
</div>
.loading {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  justify-items: center;
  column-gap: 10px;
}

.loading div {
  width: 10px;
  height: 10px;
  background-color: #1890ff;
  border-radius: 50%;
  animation: wq_scale 0.6s alternate infinite;
}

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

.loading div:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes wq_scale {
  from {
    opacity: 0.1;
    transform: scale(0.1);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

05

<div class="loading">
        <div></div>
        <div></div>
        <div></div>
        <div></div>
</div>
.loading {
  width: 40px;
  height: 40px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  justify-items: center;
  align-items: center;
  animation: rotate 1.3s linear infinite;
}

.loading div {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background-color: #1890ff;
}

.loading div:nth-child(2) {
  opacity: 0.8;
}

.loading div:nth-child(3) {
  opacity: 0.6;
}

.loading div:nth-child(4) {
  opacity: 0.4;
}

@keyframes rotate {
  to {
    transform: rotate(360deg);
  }
}

06

<div class="loading">
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
</div>
.loading {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  justify-items: center;
  column-gap: 5px;
}

.loading div {
  width: 5px;
  height: 15px;
  background-color: #1890ff;
  animation: wq_scaleY 1.2s ease-in-out infinite;
}

.loading div:nth-child(2) {
  animation-delay: 0.1s;
}

.loading div:nth-child(3) {
  animation-delay: 0.2s;
}

.loading div:nth-child(4) {
  animation-delay: 0.3s;
}

.loading div:nth-child(5) {
  animation-delay: 0.4s;
}

@keyframes wq_scaleY {
  0%,
  40%,
  100% {
    transform: scaleY(1);
  }

  20% {
    transform: scaleY(2.5);
  }
}

07

<div class="loading">
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
</div>
.loading {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  justify-items: center;
  column-gap: 5px;
  height: 30px;
  overflow-y: hidden;
}

.loading div {
  width: 5px;
  height: 50px;
  background-color: #1890ff;
  animation: wq_translateY 1s ease-in-out infinite;
}

.loading div:nth-child(2) {
  animation-delay: 0.1s;
}

.loading div:nth-child(3) {
  animation-delay: 0.2s;
}

.loading div:nth-child(4) {
  animation-delay: 0.3s;
}

.loading div:nth-child(5) {
  animation-delay: 0.4s;
}

@keyframes wq_translateY {
  0%,
  40%,
  100% {
    transform: translateY(20px);
  }

  20% {
    transform: translateY(0);
  }
}

08

<div class="loading">
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
</div>
.loading {
  display: grid;
  grid-template-columns: repeat(5, 15px);
}

.loading div {
  width: 10px;
  height: 10px;
  background-color: rgba(24, 144, 255, .5);
  position: relative;
}

.loading div:nth-child(1)::before {
  content: "";
  width: 10px;
  height: 10px;
  background-color: #1890ff;
  z-index: 1;
  position: absolute;
  left: 0;
  top: 0;
  animation: wq_step 1s steps(5, end) infinite;
}

@keyframes wq_step {
  to {
    transform: translateX(75px);
  }
}

09

<div class="loading">
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
</div>
.loading {
  display: grid;
  grid-template-columns: repeat(5, 15px);
}
.loading div {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #1890ff;
  animation: wq_load 1s ease infinite; 
}

.loading div:nth-child(1) {
  animation-delay: 0.2s;
}
.loading div:nth-child(2) {
  animation-delay: 0.4s;
}
.loading div:nth-child(3) {
  animation-delay: 0.6s;
}
.loading div:nth-child(4) {
  animation-delay: 0.8s;
}
.loading div:nth-child(5) {
  animation-delay: 1s;
}

@keyframes wq_load {
  0% {
    opacity: 1;
    transform: scale(1.3);
  }
  100% {
    opacity: 0.2;
    transform: scale(0.3);
  }
}

10

<div class="loading">
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
</div>
.loading {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  position: relative;
}

.loading .item {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  position: absolute;
}

.loading .item:nth-child(1) {
  border-bottom: 7px solid #1890ff;
  transform: rotateX(15deg) rotateY(-45deg);
  animation: rotate_one 1s linear infinite -0.8s;
}

.loading .item:nth-child(2) {
  border-bottom: 7px solid #f40968;
  transform: rotateX(50deg) rotateY(10deg);
  animation: rotate_two 1s linear infinite -0.4s;
}

.loading .item:nth-child(3) {
  border-bottom: 7px solid #77d970;
  transform: rotateX(35deg) rotateY(55deg);
  animation: rotate_three 1s linear infinite;
}

@keyframes rotate_one {
  to {
    transform: rotateX(15deg) rotateY(-45deg) rotateZ(360deg);
  }
}

@keyframes rotate_two {
  to {
    transform: rotateX(50deg) rotateY(10deg) rotateZ(360deg);
  }
}

@keyframes rotate_three {
  to {
    transform: rotateX(35deg) rotateY(55deg) rotateZ(360deg);
  }
}

Gitee

loading效果整合

  • 5
    点赞
  • 28
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
以下是两个使用CSS实现loading动画: 1. 经典款loading动画,只需一个div元素即可完成: ```css .loader-6 { width: 48px; height: 48px; border: 2px solid #FFF; border-radius: 50%; display: inline-block; position: relative; -webkit-animation: rotation 1s linear infinite; animation: rotation 1s linear infinite; } .loader-6:after { content: ""; position: absolute; left: 50%; top: 0; background: #FF3D00; width: 3px; height: 24px; transform: translateX(-50%); } @-webkit-keyframes rotation { from { -webkit-transform: rotate(0deg); transform: rotate(0deg); } to { -webkit-transform: rotate(359deg); transform: rotate(359deg); } } @keyframes rotation { from { -webkit-transform: rotate(0deg); transform: rotate(0deg); } to { -webkit-transform: rotate(359deg); transform: rotate(359deg); } } ``` 2. loader-7动画,使用多个div元素实现: ```css .loader-7 { width: 40px; height: 40px; display: flex; justify-content: space-between; align-items: center; } .loader-7 div { width: 8px; height: 8px; border-radius: 50%; background-color: #FF3D00; animation: loader-7 1s ease-in-out infinite; } .loader-7 div:nth-child(1) { animation-delay: 0s; } .loader-7 div:nth-child(2) { animation-delay: 0.1s; } .loader-7 div:nth-child(3) { animation-delay: 0.2s; } .loader-7 div:nth-child(4) { animation-delay: 0.3s; } .loader-7 div:nth-child(5) { animation-delay: 0.4s; } .loader-7 div:nth-child(6) { animation-delay: 0.5s; } .loader-7 div:nth-child(7) { animation-delay: 0.6s; } .loader-7 div:nth-child(8) { animation-delay: 0.7s; } @keyframes loader-7 { 0% { transform: scale(1); } 20% { transform: scale(1, 2.5); } 40% { transform: scale(1); } } ```

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

温情key

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值