首頁  >  文章  >  web前端  >  html5自訂遮罩的實作程式碼分享

html5自訂遮罩的實作程式碼分享

黄舟
黄舟原創
2017-03-31 13:30:092214瀏覽

html5自訂遮罩的實作程式碼分享

ys_loading.css

.ys-loading{
    position:fixed;
    top:0;
    bottom:0;
    left:0;
    right:0;
    z-index: 9999;
}
 
.ys-loading em{
    position:absolute;
    left:0;
    right:0;
    top:0;
    bottom:0;
    width:44px;
    height:44px;
    margin:auto;
    border-radius: 22px;
    opacity: 0.3;
    overflow: hidden;
}
 
.ys-loading em:before{
    content:"";
    display:block;
    width:46px;
    height:46px;
    background:url(../../images/common/ajax-loader.gif) no-repeat center center;
    background-size:contain;
    margin-top:-1px;
    margin-left:-1px;
}

ys_loading.js

(function($){
 
    var container = null;
 
    var html =  "<div class=&#39;ys-loading&#39;><em></em></div>";
 
    function render(){
        container = $(html).appendTo("body");
    }
    var initialized = false;
    function init(){
        if(initialized){
            return;
        }
        initialized = true;
        render();
    }
 
    var LoadingWidget = {
        showLoading:function(){
            init();
            container.show();
        },
        hideLoading:function(){
            container.hide();
        }
    };
 
    window.LoadingWidget = LoadingWidget;
})(jQuery);

html5自訂遮罩的實作程式碼分享

以上是html5自訂遮罩的實作程式碼分享的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn