• 纯css3 加载loading动画特效


    最近项目中要实现当页面还没有加载完给用户提示正在加载的loading,本来是想做个图片提示的,但是图片如果放大电脑的分辨率就会感觉到很虚,体验效果很不好。于是就采用css3+js实现这个loading的动画效果,最终在我们前端工程师的帮助之下完成。所以记录在这里,如果感兴趣的朋友也可以看看,大家互相焦炉学习。

    1、demo.html

    <!DOCTYPE html>
    <html>
    <head>
    
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    
    <link rel="stylesheet" type="text/css" href="./loaders.css">
    <title>纯css3 加载loading动画特效</title>
    
    </head>
    <body>
    
    <style>
    body{100%;height:100%;margin:0;}
    .fuceng{position:absolute;100%;height:100%;margin:0;}
    .loading{margin-left: 50%; margin-top:20%;}
    </style>
    
     <div> 
    	<div class="fuceng">  
          <div class="loading">
            <div class="loader-inner line-spin-fade-loader">
              <div></div>
              <div></div>
              <div></div>
              <div></div>
              <div></div>
              <div></div>
              <div></div>
              <div></div>
            </div>
          </div>
     	</div>
    </body>
    </html>
    

    2、loaders.css

    /**
     *
     * All animations must live in their own file
     * in the animations directory and be included
     * here.
     *
     */
    /**
     * Styles shared by multiple animations
     */
    /**
     */
    .ball-spin-fade-loader {
      position: relative; }
      .ball-spin-fade-loader > div:nth-child(1) {
        top: 25px;
        left: 0;
        -webkit-animation: ball-spin-fade-loader 1s 0s infinite linear;
                animation: ball-spin-fade-loader 1s 0s infinite linear; }
      .ball-spin-fade-loader > div:nth-child(2) {
        top: 17.04545px;
        left: 17.04545px;
        -webkit-animation: ball-spin-fade-loader 1s 0.12s infinite linear;
                animation: ball-spin-fade-loader 1s 0.12s infinite linear; }
      .ball-spin-fade-loader > div:nth-child(3) {
        top: 0;
        left: 25px;
        -webkit-animation: ball-spin-fade-loader 1s 0.24s infinite linear;
                animation: ball-spin-fade-loader 1s 0.24s infinite linear; }
      .ball-spin-fade-loader > div:nth-child(4) {
        top: -17.04545px;
        left: 17.04545px;
        -webkit-animation: ball-spin-fade-loader 1s 0.36s infinite linear;
                animation: ball-spin-fade-loader 1s 0.36s infinite linear; }
      .ball-spin-fade-loader > div:nth-child(5) {
        top: -25px;
        left: 0;
        -webkit-animation: ball-spin-fade-loader 1s 0.48s infinite linear;
                animation: ball-spin-fade-loader 1s 0.48s infinite linear; }
      .ball-spin-fade-loader > div:nth-child(6) {
        top: -17.04545px;
        left: -17.04545px;
        -webkit-animation: ball-spin-fade-loader 1s 0.6s infinite linear;
                animation: ball-spin-fade-loader 1s 0.6s infinite linear; }
      .ball-spin-fade-loader > div:nth-child(7) {
        top: 0;
        left: -25px;
        -webkit-animation: ball-spin-fade-loader 1s 0.72s infinite linear;
                animation: ball-spin-fade-loader 1s 0.72s infinite linear; }
      .ball-spin-fade-loader > div:nth-child(8) {
        top: 17.04545px;
        left: -17.04545px;
        -webkit-animation: ball-spin-fade-loader 1s 0.84s infinite linear;
                animation: ball-spin-fade-loader 1s 0.84s infinite linear; }
      .ball-spin-fade-loader > div {
        background-color: #279fcf;
         15px;
        height: 15px;
        border-radius: 100%;
        margin: 2px;
        -webkit-animation-fill-mode: both;
                animation-fill-mode: both;
        position: absolute; }
    
    @-webkit-keyframes line-spin-fade-loader {
      50% {
        opacity: 0.3; }
    
      100% {
        opacity: 1; } }
    
    @keyframes line-spin-fade-loader {
      50% {
        opacity: 0.3; }
    
      100% {
        opacity: 1; } }
    
    .line-spin-fade-loader {
      position: relative; }
      .line-spin-fade-loader > div:nth-child(1) {
        top: 20px;
        left: 0;
        -webkit-animation: line-spin-fade-loader 1.2s 0.12s infinite ease-in-out;
                animation: line-spin-fade-loader 1.2s 0.12s infinite ease-in-out; }
      .line-spin-fade-loader > div:nth-child(2) {
        top: 13.63636px;
        left: 13.63636px;
        -webkit-transform: rotate(-45deg);
            -ms-transform: rotate(-45deg);
                transform: rotate(-45deg);
        -webkit-animation: line-spin-fade-loader 1.2s 0.24s infinite ease-in-out;
                animation: line-spin-fade-loader 1.2s 0.24s infinite ease-in-out; }
      .line-spin-fade-loader > div:nth-child(3) {
        top: 0;
        left: 20px;
        -webkit-transform: rotate(90deg);
            -ms-transform: rotate(90deg);
                transform: rotate(90deg);
        -webkit-animation: line-spin-fade-loader 1.2s 0.36s infinite ease-in-out;
                animation: line-spin-fade-loader 1.2s 0.36s infinite ease-in-out; }
      .line-spin-fade-loader > div:nth-child(4) {
        top: -13.63636px;
        left: 13.63636px;
        -webkit-transform: rotate(45deg);
            -ms-transform: rotate(45deg);
                transform: rotate(45deg);
        -webkit-animation: line-spin-fade-loader 1.2s 0.48s infinite ease-in-out;
                animation: line-spin-fade-loader 1.2s 0.48s infinite ease-in-out; }
      .line-spin-fade-loader > div:nth-child(5) {
        top: -20px;
        left: 0;
        -webkit-animation: line-spin-fade-loader 1.2s 0.6s infinite ease-in-out;
                animation: line-spin-fade-loader 1.2s 0.6s infinite ease-in-out; }
      .line-spin-fade-loader > div:nth-child(6) {
        top: -13.63636px;
        left: -13.63636px;
        -webkit-transform: rotate(-45deg);
            -ms-transform: rotate(-45deg);
                transform: rotate(-45deg);
        -webkit-animation: line-spin-fade-loader 1.2s 0.72s infinite ease-in-out;
                animation: line-spin-fade-loader 1.2s 0.72s infinite ease-in-out; }
      .line-spin-fade-loader > div:nth-child(7) {
        top: 0;
        left: -20px;
        -webkit-transform: rotate(90deg);
            -ms-transform: rotate(90deg);
                transform: rotate(90deg);
        -webkit-animation: line-spin-fade-loader 1.2s 0.84s infinite ease-in-out;
                animation: line-spin-fade-loader 1.2s 0.84s infinite ease-in-out; }
      .line-spin-fade-loader > div:nth-child(8) {
        top: 13.63636px;
        left: -13.63636px;
        -webkit-transform: rotate(45deg);
            -ms-transform: rotate(45deg);
                transform: rotate(45deg);
        -webkit-animation: line-spin-fade-loader 1.2s 0.96s infinite ease-in-out;
                animation: line-spin-fade-loader 1.2s 0.96s infinite ease-in-out; }
      .line-spin-fade-loader > div {
        background-color: #279fcf;
         4px;
        height: 35px;
        border-radius: 2px;
        margin: 2px;
        -webkit-animation-fill-mode: both;
                animation-fill-mode: both;
        position: absolute;
         5px;
        height: 15px; }
    

    3、效果图

  • 相关阅读:
    刷水题(四)
    C++如何调试
    刷水题(三)
    刷水题(二)
    虔诚的墓主人(BZOJ1227)(洛谷P2154)解题报告
    同余方程组(EXCRT)(luogu4777)
    数据结构——树状数组详解
    程序自动分析(NOI2015)(洛谷P1955)题解
    小胖的奇偶(Viojs1112)题解
    小胖守皇宫(VIJOS P1144 )题解
  • 原文地址:https://www.cnblogs.com/gxbk629/p/6092674.html
Copyright © 2020-2023  润新知