利用CSS3打造十种Loading效果

第1种效果:

2849764-9abc1ae848a17b40.gif

代码如下:

html

css

立即学习“前端免费学习笔记(深入)”;

.loading{            width: 80px;            height: 40px;            margin: 0 auto;            margin-top:100px;        }        .loading span{            display: inline-block;            width: 8px;            height: 100%;            border-radius: 4px;            background: lightgreen;            -webkit-animation: load 1s ease infinite;        }        @-webkit-keyframes load{            0%,100%{                height: 40px;                background: lightgreen;            }            50%{                height: 70px;                margin: -15px 0;                background: lightblue;            }        }        .loading span:nth-child(2){            -webkit-animation-delay:0.2s;        }        .loading span:nth-child(3){            -webkit-animation-delay:0.4s;        }        .loading span:nth-child(4){            -webkit-animation-delay:0.6s;        }        .loading span:nth-child(5){            -webkit-animation-delay:0.8s;        }

第2种效果

1870882-0907cd9141efb919.gif

.loading{            width: 150px;            height: 4px;            border-radius: 2px;            margin: 0 auto;            margin-top:100px;            position: relative;            background: lightgreen;            -webkit-animation: changeBgColor 1.04s ease-in infinite alternate;        }        .loading span{            display: inline-block;            width: 16px;            height: 16px;            border-radius: 50%;            background: lightgreen;            position: absolute;            margin-top: -7px;            margin-left:-8px;            -webkit-animation: changePosition 1.04s ease-in infinite alternate;        }        @-webkit-keyframes changeBgColor{            0%{                background: lightgreen;            }            100%{                background: lightblue;            }        }        @-webkit-keyframes changePosition{            0%{                background: lightgreen;            }            100%{                margin-left: 142px;                background: lightblue;            }        }

第3-5种效果:

1870882-04198c3aab3983c4.gif

1870882-df565498d033eec7.gif.0

1870882-96efcbde579c4772.gif

3

.loading{            width: 150px;            height: 15px;            margin: 0 auto;            margin-top:100px;        }        .loading span{            display: inline-block;            width: 15px;            height: 100%;            margin-right: 5px;            border-radius: 50%;            background: lightgreen;            -webkit-animation: load 1.04s ease infinite;        }        .loading span:last-child{            margin-right: 0px;         }        @-webkit-keyframes load{            0%{                opacity: 1;            }            100%{                opacity: 0;            }        }        .loading span:nth-child(1){            -webkit-animation-delay:0.13s;        }        .loading span:nth-child(2){            -webkit-animation-delay:0.26s;        }        .loading span:nth-child(3){            -webkit-animation-delay:0.39s;        }        .loading span:nth-child(4){            -webkit-animation-delay:0.52s;        }        .loading span:nth-child(5){            -webkit-animation-delay:0.65s;        }

4

.loading{            width: 150px;            height: 15px;            margin: 0 auto;            margin-top:100px;        }        .loading span{            display: inline-block;            width: 15px;            height: 100%;            margin-right: 5px;            border-radius: 50%;            background: lightgreen;            -webkit-animation: load 1.04s ease infinite;        }        .loading span:last-child{            margin-right: 0px;         }        @-webkit-keyframes load{            0%{                opacity: 1;                -webkit-transform: scale(1.3);            }            100%{                opacity: 0.2;                -webkit-transform: scale(.3);            }        }        .loading span:nth-child(1){            -webkit-animation-delay:0.13s;        }        .loading span:nth-child(2){            -webkit-animation-delay:0.26s;        }        .loading span:nth-child(3){            -webkit-animation-delay:0.39s;        }        .loading span:nth-child(4){            -webkit-animation-delay:0.52s;        }        .loading span:nth-child(5){            -webkit-animation-delay:0.65s;        }

5

.loading{            width: 150px;            height: 15px;            margin: 0 auto;            position: relative;            margin-top:100px;        }        .loading span{            position: absolute;            width: 15px;            height: 100%;            border-radius: 50%;            background: lightgreen;            -webkit-animation: load 1.04s ease-in infinite alternate;        }        @-webkit-keyframes load{            0%{                opacity: 1;                -webkit-transform: translate(0px);            }            100%{                opacity: 0.2;                -webkit-transform: translate(150px);            }        }        .loading span:nth-child(1){            -webkit-animation-delay:0.13s;        }        .loading span:nth-child(2){            -webkit-animation-delay:0.26s;        }        .loading span:nth-child(3){            -webkit-animation-delay:0.39s;        }        .loading span:nth-child(4){            -webkit-animation-delay:0.52s;        }        .loading span:nth-child(5){            -webkit-animation-delay:0.65s;        }

第6-8种效果:

1870882-5a3034fa3fd0df50.gif

1870882-e5a362524daee8eb.gif

1870882-9cdbfdd869da9d85.gif

.loading{            width: 150px;            height: 15px;            margin: 0 auto;            margin-top:100px;            text-align: center;        }        .loading span{            display: inline-block;            width: 15px;            height: 100%;            margin-right: 5px;            background: lightgreen;            -webkit-animation: load 1.04s ease infinite;        }        .loading span:last-child{            margin-right: 0px;         }        @-webkit-keyframes load{            0%{                opacity: 1;            }            100%{                opacity: 0;            }        }        .loading span:nth-child(1){            -webkit-animation-delay:0.13s;        }        .loading span:nth-child(2){            -webkit-animation-delay:0.26s;        }        .loading span:nth-child(3){            -webkit-animation-delay:0.39s;        }        .loading span:nth-child(4){            -webkit-animation-delay:0.52s;        }        .loading span:nth-child(5){            -webkit-animation-delay:0.65s;        }
.loading{            width: 150px;            height: 15px;            margin: 0 auto;            margin-top:100px;        }        .loading span{            display: inline-block;            width: 15px;            height: 100%;            margin-right: 5px;            background: lightgreen;            -webkit-transform-origin: right bottom;            -webkit-animation: load 1s ease infinite;        }        .loading span:last-child{            margin-right: 0px;         }        @-webkit-keyframes load{            0%{                opacity: 1;            }            100%{                opacity: 0;                -webkit-transform: rotate(90deg);            }        }        .loading span:nth-child(1){            -webkit-animation-delay:0.13s;        }        .loading span:nth-child(2){            -webkit-animation-delay:0.26s;        }        .loading span:nth-child(3){            -webkit-animation-delay:0.39s;        }        .loading span:nth-child(4){            -webkit-animation-delay:0.52s;        }        .loading span:nth-child(5){            -webkit-animation-delay:0.65s;        }
.loading{            width: 150px;            height: 15px;            margin: 0 auto;            margin-top:100px;        }        .loading span{            display: inline-block;            width: 15px;            height: 100%;            margin-right: 5px;            background: lightgreen;            -webkit-transform-origin: right bottom;            -webkit-animation: load 1s ease infinite;        }        .loading span:last-child{            margin-right: 0px;         }        @-webkit-keyframes load{            0%{                opacity: 1;                -webkit-transform: scale(1);            }            100%{                opacity: 0;                -webkit-transform: rotate(90deg) scale(.3);            }        }        .loading span:nth-child(1){            -webkit-animation-delay:0.13s;        }        .loading span:nth-child(2){            -webkit-animation-delay:0.26s;        }        .loading span:nth-child(3){            -webkit-animation-delay:0.39s;        }        .loading span:nth-child(4){            -webkit-animation-delay:0.52s;        }        .loading span:nth-child(5){            -webkit-animation-delay:0.65s;        }

第9-10种效果:

1870882-558630dc8a5e5242.gif

1870882-bc1bf928af5b87fe.gif

.loadEffect{            width: 100px;            height: 100px;            position: relative;            margin: 0 auto;            margin-top:100px;        }        .loadEffect span{            display: inline-block;            width: 16px;            height: 16px;            border-radius: 50%;            background: lightgreen;            position: absolute;            -webkit-animation: load 1.04s ease infinite;        }        @-webkit-keyframes load{            0%{                opacity: 1;            }            100%{                opacity: 0.2;            }        }        .loadEffect span:nth-child(1){            left: 0;            top: 50%;            margin-top:-8px;            -webkit-animation-delay:0.13s;        }        .loadEffect span:nth-child(2){            left: 14px;            top: 14px;            -webkit-animation-delay:0.26s;        }        .loadEffect span:nth-child(3){            left: 50%;            top: 0;            margin-left: -8px;            -webkit-animation-delay:0.39s;        }        .loadEffect span:nth-child(4){            top: 14px;            right:14px;            -webkit-animation-delay:0.52s;        }        .loadEffect span:nth-child(5){            right: 0;            top: 50%;            margin-top:-8px;            -webkit-animation-delay:0.65s;        }        .loadEffect span:nth-child(6){            right: 14px;            bottom:14px;            -webkit-animation-delay:0.78s;        }        .loadEffect span:nth-child(7){            bottom: 0;            left: 50%;            margin-left: -8px;            -webkit-animation-delay:0.91s;        }        .loadEffect span:nth-child(8){            bottom: 14px;            left: 14px;            -webkit-animation-delay:1.04s;        }
.loadEffect{            width: 100px;            height: 100px;            position: relative;            margin: 0 auto;            margin-top:100px;        }        .loadEffect span{            display: inline-block;            width: 20px;            height: 20px;            border-radius: 50%;            background: lightgreen;            position: absolute;            -webkit-animation: load 1.04s ease infinite;        }        @-webkit-keyframes load{            0%{                -webkit-transform: scale(1.2);                opacity: 1;            }            100%{                -webkit-transform: scale(.3);                opacity: 0.5;            }        }        .loadEffect span:nth-child(1){            left: 0;            top: 50%;            margin-top:-10px;            -webkit-animation-delay:0.13s;        }        .loadEffect span:nth-child(2){            left: 14px;            top: 14px;            -webkit-animation-delay:0.26s;        }        .loadEffect span:nth-child(3){            left: 50%;            top: 0;            margin-left: -10px;            -webkit-animation-delay:0.39s;        }        .loadEffect span:nth-child(4){            top: 14px;            right:14px;            -webkit-animation-delay:0.52s;        }        .loadEffect span:nth-child(5){            right: 0;            top: 50%;            margin-top:-10px;            -webkit-animation-delay:0.65s;        }        .loadEffect span:nth-child(6){            right: 14px;            bottom:14px;            -webkit-animation-delay:0.78s;        }        .loadEffect span:nth-child(7){            bottom: 0;            left: 50%;            margin-left: -10px;            -webkit-animation-delay:0.91s;        }        .loadEffect span:nth-child(8){            bottom: 14px;            left: 14px;            -webkit-animation-delay:1.04s;        }

推荐CSS教程:《CSS教程》

以上就是利用CSS3打造十种Loading效果的详细内容,更多请关注创想鸟其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/1615076.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2025年12月24日 04:44:03
下一篇 2025年12月24日 04:44:23

相关推荐

  • 详解css中的content属性的用法

    content属性一般用于::before、::after伪元素中,用于呈现伪元素的内容。 用法详解 1、插入纯字符 *{margin: 0;padding: 0;box-sizing: border-box;} li{list-style: none;} .content{ position: r…

    2025年12月24日 好文分享
    000
  • CSS3实现卡片效果

    第一步:确定 HTML 代码结构 在创建 HTML 代码前,你首先应该想象它的结构。当你有一个好的模型时,应该第一时间把你想象的页面结构或者你的 CSS 模块及时地在纸上罗列出来。一个设计合理、结构良好的 HTML 页面会让你在接下来的工作过程中变的一异常轻松。 利用css制作卡片UI — 墨丶水…

    2025年12月24日
    000
  • CSS中7个你必须知道属性

    学习css是构建好看网页的一种方式。 但是,在学习过程中,我们倾向于(大部分时间)限制自己,一遍又一遍地使用相同的属性。 毕竟,我们是一种习惯性的动物,我们会使用自己习惯且熟悉的东西。 因此,在这篇文章中,向你介绍7个 比较少见且好用的 CSS 属性,希望对你有所帮助。 1. vertical-al…

    2025年12月24日 好文分享
    000
  • 最受欢迎的10大CSS框架

    web 开发工程师在开发页面样式的时候需要花费大量的时间开发,其中最头疼的还是浏览器的兼容性问题,最省事的是使用 css 框架,幸运的是一些大神编写了一套精美的 css 框架并开源出来,那么有哪些不错的 css 框架呢? 我收集了一些资料和数据来和大家讨论,下面我就说说 Github 上 star …

    好文分享 2025年12月24日
    000
  • css中如何禁用a标签按钮

    首先我们知道a标签是没有disabled属性的,那么我们该如何实现a标签按钮的禁用呢? 解决方法: 方法一:移除点击事件click或touchend 我们可以直接使用jquery:unbind()或者JS:removeEventListener()移除点击事件。 (视频教程推荐:css视频教程) 方…

    2025年12月24日
    000
  • CSS之简单的响应式的实现

    一、允许网页宽度自动调整 首先,在网页代码的头部,加入一行viewport元标签。 viewport是网页默认的宽度和高度,上面这行代码的意思是,网页宽度默认等于屏幕宽度(width=device-width),原始缩放比例(initial-scale=1)为1.0,即网页初始大小占屏幕面积的100…

    2025年12月24日
    000
  • css实现禁止选中文本

    css代码: .box { /* 禁止选中文本 */ -moz-user-select: none; /*火狐*/ -webkit-user-select: none; /*webkit浏览器*/ -ms-user-select: none; /*IE10*/ -khtml-user-select:…

    2025年12月24日
    000
  • CSS 9种方法实现不定宽高的垂直水平居中(干货)

    有常见的 flex、transform、absolute 等等。也有 css3 的网格布局。还有伪元素的方法,是的,你没有看错,::after 和 ::before 也可以实现居中。 1、flex 大家的第一反应,可能就是 flex 了。因为它的写法够简单直观,兼容性也没什么问题。是手机端居中方式的…

    2025年12月24日
    000
  • css如何实现边框长度控制功能

    以前需要边框长度比容器小一些时,我用div嵌套。后来发现伪类在实现这个效果时很方便,只需要一个div就够了,另外调整padding和margin都不会很麻烦。 (推荐教程:CSS入门教程) border topborder leftborder rightborder bottom .box-con…

    2025年12月24日
    000
  • 详细介绍css属性之媒体类型

    前言: 样式单的一个最重要的特点就是它可以作用于多种媒体,比如页面、屏幕、电子合成器等等。特定的属性只能作用于特定的媒体,如”font-size”属性只对可卷动的媒体类型有效(屏幕)。 声明一个媒体属性可以用@import或@media引入: @import url(loud…

    2025年12月24日
    000
  • css如何实现给div添加滚动并隐藏滚动条

    css 给div添加滚动并隐藏滚动条 ,具体代码如下所示:  在html中 下面内容会单独滚动 1111111111111111 222222222222222 Linfo.ai Linfo AI 是一款AI驱动的 Chrome 扩展程序,可以将网页文章、行业报告、YouTube 视频和 PDF 文…

    2025年12月24日 好文分享
    000
  • css中的content属性该如何使用

    content属性一般用于::before、::after伪元素中,用于呈现伪元素的内容。平时content属性值我们用的最多的就是给个纯字符,其实它还有很多值可供选择。 1、插入纯字符 *{margin: 0;padding: 0;box-sizing: border-box;} li{list-…

    2025年12月24日
    000
  • 关于css中的类名问题的介绍

    以下以数字开头的 css 类名不会生效: .1st{ color: red;} 一个合法的 CSS 类名必需以下面其中之一作为开头: 1、下划线 _ 2、短横线 – 3、字母 a – z 立即学习“前端免费学习笔记(深入)”; 然后紧跟其他 _ , – 数字或字母…

    2025年12月24日
    000
  • css如何实现网页背景动态渐变效果

    html部分: 渐变——天际线 渐变——天际线 实现背景颜色渐变不需要在HTML(结构)部分做任何操作 这里加了一行字,方便显示效果; (推荐教程:CSS教程) CSS部分: body{ margin: 0; padding: 0; font-family: “montserrat”; backgr…

    2025年12月24日
    000
  • css如何解决图片底部空白缝隙问题

    问题描述: 引用图片时下方总出现空白,情况如下图所示。 css代码: .img-box { border: 2px solid red; width: 550px; } @@##@@ 原因分析: 立即学习“前端免费学习笔记(深入)”; 行内块元素会和文字的基线对齐。 (推荐教程:CSS教程) 解决方…

    2025年12月24日
    000
  • css实现文字竖排效果

    html中文字的默认排列是横向排列的,但一些特殊情况下是需要文字竖向排列的。 单行文字竖向排列 .onecn{ width: 20px; margin: 0 auto; line-height: 24px; } (推荐教程:CSS入门教程) 立即学习“前端免费学习笔记(深入)”; .oneen{ w…

    2025年12月24日 好文分享
    000
  • css实现文本图标对齐的方法

    开发中遇见图片跟文字放在一行显示是最常见不过的了,两个行内元素的对齐通常也是最令人头疼,有时候明明使用了最常用的对齐方法,却总还是有些许偏差,先来看一个最基本的示例: html部分: @@##@@ xx测试对齐Style- 推荐教程:CSS入门教程 css部分: .wrap { width: 300…

    2025年12月24日 好文分享
    000
  • css如何实现三栏布局

    实现方法: 一、float浮动 .layout.float .left-right-center{ height: 100px; } .layout.float .left{ float: left; width: 300px; background-color: red; } .layout.fl…

    2025年12月24日
    000
  • css如何使用Rem布局实现自适应效果

    为什么要自适应? 比如,对于一个移动端页面,设计师给的视觉稿画布宽 750,视觉稿中的一个黄色区块的尺寸是 702 x 300,并在画板中居中。我们希望在任何一个设备中的呈现比例都与视觉稿中一样,根据布局视口宽度等比缩放。 在移动端我们一般会设置布局视口宽度=设备宽度,即内容呈现的区域在设备屏幕内。…

    2025年12月24日 好文分享
    000
  • 如何使用css来画一个棒棒糖

    先来看一下效果图: (相关视频教程推荐:css视频教程) CSS代码: 棒棒糖 用css画一个棒棒糖 要求:立即学习“前端免费学习笔记(深入)”; Linfo.ai Linfo AI 是一款AI驱动的 Chrome 扩展程序,可以将网页文章、行业报告、YouTube 视频和 PDF 文档转换为结构化…

    2025年12月24日 好文分享
    200

发表回复

登录后才能评论
关注微信