栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

jquery实现页面等待加载“转圈”效果

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

jquery实现页面等待加载“转圈”效果

1.js全部源码,loading.js
      function initLoading(property) {
        $("body .loading-box-shadow-omg").remove();//清除加载图层
        if(property.type=="stop"){
            return;
        }
        var nodeHtml = '';
        nodeHtml += '';
        $("body").append(nodeHtml);//加载布局元素
        var html = '';
        html += '';
        html += '';
        html += '';
        html += '';
        html += '';
        html += '';
        html += '';
        $("body .loading-circle").html(html);
        var content = "正在加载中...";//提示内容
        if(property.content){
            content = property.content;
        }
        $("body .loading-content").text(content);
        var shadowColor = "#211f1f5c";//阴影颜色
        if(property.shadowColor){
            shadowColor = property.shadowColor;
            $('body .loading-box-shadow-omg').css("background-color",shadowColor);
        }
        var loadingBoxColor = "white";//加载框背景色
        if(property.loadingBoxColor){
            loadingBoxColor = property.loadingBoxColor;
            $('body .loading-box-shadow-omg .loading-box').css("background-color",loadingBoxColor);
        }
        var loadingPointColor = "#292961";//动态点颜色
        if(property.loadingPointColor){
            loadingPointColor = property.loadingPointColor;
            $('body .loading-box-shadow-omg .loading-circle>div').css("background-color",loadingPointColor);
        }
        var loadingContentColor = "rebeccapurple";//提示内容颜色
        if(property.loadingContentColor){
            loadingContentColor = property.loadingContentColor;
            $('body .loading-box-shadow-omg .loading-content').css("color",loadingContentColor);
        }
    };
	initLoading({
    type:"start",
    content:"loading...",
    // shadowColor:"grey",
    // loadingBoxColor:"yellow",
    // loadingPointColor:"green",
    // loadingContentColor:"red"
});

2.css全部源码,loading.css(ps:gif图都不用找UI了,嘿嘿,不过肯定没UI的精美)
html body{
    margin: 0;
    padding: 0;
}


body .loading-box-shadow-omg{
    width: -webkit-fill-available;
    height: -webkit-fill-available;
    background-color: #211f1f5c;
    position: absolute;
    top: 0;
    z-index: 9999999;
}

.hidden{
    display: none!important;
}

body .loading-box-shadow-omg .loading-box{
    background-color: white;
    border-radius: 5px;
    position: absolute;
    top: 20%;
    left: 40%;
    width: 20%;
    height: 25%;
}

body .loading-box-shadow-omg .loading-box .loading-circle{
    width: 80px;
    height: 80px;
    background-color: transparent;
    position: absolute;
    left: 35%;
    top: 10%;
    animation: init-circle 1s linear infinite;
}

body .loading-box-shadow-omg .loading-box .loading-content{
    position: absolute;
    bottom: 5%;
    font-weight: bold;
    color: rebeccapurple;
    width: 100%;
    text-align: center;
}

body .loading-box-shadow-omg .loading-box .loading-circle>div{
    background-color: #292961;
    border-radius: 20px;
    position: absolute;
}

@keyframes init-circle {
    from{
        transform: rotate(360deg);
    }
    to{
        transform: rotate(0deg);
    }
}


3.html全部源码,loading.html



    
    hello
    








效果图

4.调用initLoading方法时,可以自定义阴影遮盖颜色,转圈圈颜色等设置,属性设置方面,见js注释
initLoading({
    type:"start",
    content:"loading...",
    // shadowColor:"grey",
    // loadingBoxColor:"yellow",
    // loadingPointColor:"green",
    // loadingContentColor:"red"
});```

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/999920.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号