• 前端页面loading效果(CSS实现)


    当首页内容或图片比较多时,加载时间会比较长,此时可能出现页面白屏的情况,用户体验较差。所以,在页面完全加载出来之前,可以考虑加入loading效果,当页面完全加载完后,是loading消失即可。

    1. 方法

    html:

    在页面开头部分加入:

    <div id="loading">
        <div class="loadingImage"></div>
    </div>
    

    js:

    在页面最后面引入:

    $("#loading").fadeOut(400);
    

    css:

    #loading {
        background: #f3815e;
        position: fixed;
        left: 0;
        top: 0;
         100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 999;
    }
    
    .loadingImage {
        position: relative;
         30px;
        height: 30px;
        background: #2e98df;
        border-radius: 50px;
        animation: loadingImage 1.5s infinite linear;
    }
    
    .loadingImage::after {
        position: absolute;
         50px;
        height: 50px;
        border-top: 10px solid #b160d1;
        border-bottom: 10px solid #b160d1;
        border-left: 10px solid transparent;
        border-right: 10px solid transparent;
        border-radius: 50px;
        content: '';
        top: -20px;
        left: -20px;
        animation: loadingImage_after 1.5s infinite linear;
    }
    
    @keyframes loadingImage {
        0% {
            transform: rotate(0deg);
        }
    
        50% {
            transform: rotate(180deg);
            background: #2ecc71;
        }
    
        100% {
            transform: rotate(360deg);
        }
    }
    
    @keyframes loadingImage_after {
        0% {
            border-top: 10px solid #b160d1;
            border-bottom: 10px solid #b160d1;
        }
    
        50% {
            border-top: 10px solid #2e98df;
            border-bottom: 10px solid #2e98df;
        }
    
        100% {
            border-top: 10px solid #b160d1;
            border-bottom: 10px solid #b160d1;
        }
    }
    

    2. 效果如图:

    https://www.cnblogs.com/images/cnblogs_com/cckui/1362893/o_loading.gif

    3. loading效果图汇总

  • 相关阅读:
    递归 例子 c
    Static和extern关键字 c
    typedef的作用
    预编译指令包括:宏定义;条件编译;文件包含(就是include)
    枚举 c
    结构体 可以由多个不同类型的数据构成
    变量类型 c
    指针类型:非常重要 c
    设计模式学习--原型模式
    设计模式学习--工厂方法模式
  • 原文地址:https://www.cnblogs.com/cckui/p/10119729.html
Copyright © 2020-2023  润新知