页面加载时loading效果

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <style>
        #loading{position:fixed;top:0;left:0;width:100%;height:100%;opacity:0.6;z-index:15000;}
        #loading img{position:absolute;top:50%;left:50%;width:60px;height:60px;margin-top:-30px;margin-left:-30px;background: white;}
    </style>
    <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.js"></script>
</head>
<body>
<script type="text/javascript">
    $(function() {
        var loading = '<div id="loading"><img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1504002746731&di=a7d82714e2b6a150ecb6ab45d2dc73b9&imgtype=0&src=http%3A%2F%2Falcastongallery.com.au%2Fassets%2Fimages%2Fajax-loader.gif"></div>';
        $('body').append($(loading));

        setTimeout(function () {
            $('#loading').remove();
        }, 3000);
    });

</script>
</body>
</html>

 

posted @ 2017-08-29 16:09  徐同保  阅读(304)  评论(0编辑  收藏  举报