一个Loading 遮罩效果
2015-02-10 13:23
155 查看
1、需要两个DIV,一个用来遮罩,另一个用来显示Loading图片和文字(初始时它们是隐藏的)
2、需要用的时候,通过JS脚本修改其隐藏为显示,并且调整大小和位置
3、还需注册下滚动条事件,保持 图片和文字 DIV 总是居中显示
.gdiv_over { display: none; position: absolute; top: 0; left: 0; background-color: #f5f5f5; opacity: 0.5; z-index: 1000; border: 0; } .gdiv_layout { display: none; padding: 5px 5px 0 0; position: absolute; width: 200px; height: 45px; z-index: 1001; text-align: center; background-color: #fff; vertical-align: middle; border: 3px solid #428bca; }
<div class="gdiv_over"></div> <div class="gdiv_layout"> <img style="width: 30px; height: 30px; border: 0" src="../img/ajaxloading.gif" title="正在处理,请稍后...." /> <span style="font-size: 16px">正在处理,请稍后....</span> </div>
2、需要用的时候,通过JS脚本修改其隐藏为显示,并且调整大小和位置
function show_LoadingDIV() { //遮罩 $(".gdiv_over").height($(document).height()); $(".gdiv_over").show("slow"); //计算 Top var dh = $(window).height(); var sh = $(window).scrollTop(); var lh = $(".gdiv_layout").height(); var cha = (dh / 2) + sh - (lh / 2); $(".gdiv_layout").css("top", cha); //计算 Left var dh = $(window).width(); var lh = $(".gdiv_layout").width(); var cha2 = (dh / 2) - (lh / 2); $(".gdiv_layout").css("left", cha2); //Loading图片 和 文字 $(".gdiv_layout").show("slow"); } function hide_LoadingDIV() { $(".gdiv_over").hide("slow"); $(".gdiv_layout").hide("slow"); }
3、还需注册下滚动条事件,保持 图片和文字 DIV 总是居中显示
$(document).ready(function() { $(window).scroll(function() { if ($(".gdiv_over").css("display") != "none") { //上下滚动 左右省略 var dh = $(window).height(); var sh = $(window).scrollTop(); var lh = $(".gdiv_layout").height(); var cha = (dh / 2) + sh - (lh / 2); $(".gdiv_layout").css("top", cha); } }); });
相关文章推荐
- jquery动画 -- 3.创建一个带遮罩效果的图片走廊
- 一个仿DOS的Loading效果(轉)
- JavaScript之一个简单的loading效果
- js 遮罩层 loading 效果
- Jquery的一个loading图片效果,加载图片
- 一个基于jquery的页面预载入效果(loading)
- Flash/Flex学习笔记(45):无聊模仿同事的一个Loading效果
- 扩展easyui.datagrid,添加数据loading遮罩效果代码
- 实现一个loading加载页面的加载效果
- 一个不错的可拖动层遮罩加ALPHA滤镜(点击弹出后背景变浅色,信息提示框效果)
- 一个loading效果的实例
- 一个非常不错的loading 效果.借花献佛.
- 自己写的一个按钮控件,点击时在界面出现一个loading遮罩层
- Jquery的一个loading图片效果,加载图片
- 一个非常不错的loading 效果.借花献佛
- 一个非常不错的loading 效果.借花献佛
- 一个基于jquery的页面预载入效果(loading)
- objective-c遮罩效果一个工具类
- jquery动画3.创建一个带遮罩效果的图片走廊
- 一个非常不错的loading 效果