loading效果前端界面加载数据时的遮罩界面

<html>
<head>
	<meta charset="UTF-8">
	<link href="./loading.css" rel="stylesheet" type="text/css"/>
	<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>
<button onclick="test()">测试加载loading</button>
<script>
function test(){
	ajaxLoading('数据处理中,请稍后...');
	setTimeout(function(){
		ajaxLoadEnd()
	},2000);
}
//使用loading效果
function ajaxLoading(msg){   
	addPanelMask();
    $("<div class='datagrid-mask-msg'></div>").html(msg ? msg : "正在处理,请稍候...").appendTo("body").css({
     "display":"block",
     "z-index":99999,
     "left":($(document.body).outerWidth(true) - 190) / 2,
     "top":($(window).height() - 45) / 2
    });
 
}
 
//遮罩整个界面
function addPanelMask(){
	$("<div class='datagrid-mask'></div>").appendTo("body").css({
	"display":"block",
	"z-index":9999,
	"width":"100%",
	"height":$(window).height()
	}); 
}
 
//移除界面遮罩层
function ajaxLoadEnd(){
	$(".datagrid-mask").remove();   
	$(".datagrid-mask-msg").remove();  
}
</script>
</body>
</html>

css样式文件

.datagrid-mask {
    background: #ccc;
	position: absolute;
    left: 0;
    top: 0;
}

.datagrid-mask-msg {
	border-color: #D3D3D3;
    position: absolute;
    margin-top: -20px;
    padding: 10px 5px 10px 30px;
    width: auto;
    height: 16px;
    border-width: 2px;
    border-style: solid;
	background: #ffffff url(images/loading.gif) no-repeat scroll 5px center;
}

引入的loading的图片

效果:

  • 0
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值