当前位置: 首页 > news >正文

CSS3实现动画加载效果

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>加载效果</title>
    <link rel="stylesheet" href="./style.css" />
  </head>
  <body>
  	<!-- 弹跳加载动画 -->
    <div class="bouncing-loader">
      <div class="bouncing-loader-item"></div>
      <div class="bouncing-loader-item"></div>
      <div class="bouncing-loader-item"></div>
    </div>

	<!-- 旋转加载动画 -->
    <div class="spin-loading">
      <div class="loading"></div>
    </div>

	<!-- 点点点加载动画 -->
    <span class="dot">正在加载中<span class="dotted"></span></span>
  </body>
</html>
/* style.css */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  display: flex;
}
/* 弹跳加载效果 */
.bouncing-loader,
.spin-loading,
.dot {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 150px;
  border: 1px solid #efefef;
  margin: 3rem;
}
.bouncing-loader-item {
  width: 16px;
  height: 16px;
  margin: 3rem 0.2rem;
  background-color: #0b16f1;
  border-radius: 50%;
  animation: bouncingLoader 0.6s infinite alternate;
}
.bouncing-loader-item:nth-child(2) {
  animation-delay: 0.2s;
}
.bouncing-loader-item:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes bouncingLoader {
  to {
    opacity: 0.1;
    transform: translate3d(0, -10px, 0);
  }
}

/* 旋转动画效果 */
.spin-loading .loading {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 100%;
  /* 锥形渐变 */
  background-image: conic-gradient(#0b16f1, 30%, #fff);
  /* 使用蒙版将中间变为透明 */
  -webkit-mask-image: radial-gradient(closest-side, transparent 80%, black 80%);
  /* 开启动画 */
  animation: spin 1s linear infinite reverse;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}
/* ...动画效果 */
.dotted {
  display: inline-block;
  width: 20px;
}
.dotted::after {
  content: '';
  animation: dotted 2s infinite;
}
@keyframes dotted {
  0% {
    content: '...';
  }
  25% {
    content: '';
  }
  50% {
    content: '.';
  }
  75% {
    content: '..';
  }
  100% {
    content: '...';
  }
}

在这里插入图片描述

相关文章:

  • nginx-proxy反向代理缓存
  • Unity可视化Shader工具ASE介绍——3、ASE的Shader类型介绍
  • ds套dp——考虑位置转移or值域转移:CF1762F
  • Flink--9、双流联结(窗口联结、间隔联结)
  • 读书笔记--未来简史关键金句和阅读感悟
  • 「专题速递」JPEG AI、端到端图像编码的标准化及产品落地、深度学习
  • Angular学习笔记:路由
  • 攻防世界-fakebook
  • Python 无废话-办公自动化Excel修改数据
  • 【高性能计算】CUDA编程之OpenCV的应用(教程与代码-4)//test error
  • kubectl系列(六)-kubectl describe
  • ArcMap:第二届全国大学生GIS技能大赛(广西师范学院)详解-上午题
  • 阶段六-Day01-Linux入门
  • 【12】c++设计模式——>单例模式练习(任务队列)
  • Charles:移动端抓包 / windows客户端 iOS手机 / 手机访问PC本地项目做调试
  • R²决定系数
  • Day4:Linux系统编程1-60P
  • c语言进阶部分详解(详细解析字符串常用函数,并进行模拟实现(下))
  • 多线程锁-synchronized字节码分析
  • 自动驾驶:未来的道路上的挑战与机遇
  • 佩斯科夫:若普京认为必要,将公布土耳其谈判俄方代表人选
  • 来伊份发布关于消费者反映蜜枣粽问题处理的情况说明:与消费者达成和解
  • 沈阳一超市疑借领养名义烹食流浪狗,当地市监局:已收到多起投诉
  • 泽连斯基批准美乌矿产协议
  • 世界期待中美对话合作带来更多确定性和稳定性
  • 第二期人工智能能力建设研讨班在京开班,近40国和区域组织代表参加