≡
  • 网络编程
  • 数据库
  • CMS技巧
  • 软件编程
  • PHP笔记
  • JavaScript
  • MySQL
位置:首页 > 网络编程 > jQuery

JQUERY 居中弹出层的简单示例

人气:636 时间:2018-09-27

这篇文章主要为大家详细介绍了JQUERY 居中弹出层的简单示例,具有一定的参考价值,可以用来参考一下。

css部分

/**
 * @param 
 * @arrange (512.笔记) www.q1010.com
 **/
/*ie6居中显示层的样式*/
.chagetop { left:expression(eval(document.documentElement.scrollLeft+ (document.documentElement.clientWidth-this.offsetWidth)/2));
top:expression(eval(document.documentElement.scrollTop+ (document.documentElement.clientHeight-this.offsetHeight)/2));z-index:9999999;
}
/*遮罩*/
.overlay { background:#000; cursor: pointer; display: block; filter:alpha(opacity=60); opacity: 0.6; height:100%; width:100%; position:absolute; left:expression(eval(document.documentElement.scrollLeft));
top:expression(eval(document.documentElement.scrollTop));
z-index:9999998;width:100%}


js部分

/**
* @param 
* @arrange (512.笔记) www.q1010.com
* 参数说明:
* name为要弹出的层的id;
* overlay为遮罩,如果为0则不显示遮罩;
* position为定位方式,如果为0则不居中定位;
* 注意:为了兼容ie6请不要忘记引入glayes.css这个文件
*/
(function($) {
$.fn.gLayers = function(opts) {
var def = {
name: "#j-gl-bt",
overlay: 1,
position: 1
};
var opts = $.extend(def, opts),
target = opts.name,
ol = opts.overlay,
pst = opts.position;
return this.each(function(i) { /*添加遮罩*/
var isIE = $.browser.msie && !$.support.opacity,
isIE6 = isIE && $.browser.version < 7,
od = $(target),
itop = (document.documentElement.clientHeight – od.height()) / 2,
ileft = (document.documentElement.clientWidth – od.width()) / 2;
if(ol != 0) {
if(!$("#gl-Overlay").length > 0) {
if(!isIE6) {
$("body").append("<div id=’gl-Overlay’ style=’background:#000;cursor: pointer;display: block;filter:alpha(opacity=60);opacity: 0.6;height:100%;width:100%; position: fixed; left: 0;top: 0;z-index:9999998′></div>")
} else {
$("html").css({
"height": "100%"
});
$("body").css({
"height": "100%"
});
$("body").append("<div id=’gl-Overlay’ class=’overlay’><iframe frameborder=0 id=’frame1′ style=’filter:alpha(opacity=10);opacity: 0.6;height:100%;width:100%;’></iframe></div>")
}
}
};
/*添加遮罩 end*/

/* 实现弹出 */
if(pst != 0) {
$("#gl-Overlay").show();
if(!isIE6) {
od.css("top", itop).css("left", ileft).css("position", "fixed").css("z-index", "9999999").show();
} else {
od.css("position", "absolute").show();
od.addClass("chagetop");
}
}else{od.show()
}

/*关闭按钮*/
$(".j-gl-c").click(function() {
$(target).hide();
$("#gl-Overlay").remove();
return false;
});
});
}
})(jQuery);

本文来自:http://www.q1010.com/180/2080-0.html

注:关于JQUERY 居中弹出层的简单示例的内容就先介绍到这里,更多相关文章的可以留意四海网的其他信息。

关键词:

您可能感兴趣的文章

上一篇:JQUERY ON()方法支持的所有事件功能实例
下一篇:JQUERY 图片放大镜的简单示例
热门文章
  • jquery 一键复制到剪贴板的简单示例
  • Js动态添加复选框Checkbox的简单示例
  • jQuery 使用CSS()方法改变CSS样式的简单示例
  • jQuery 使用label实现点击表单input,提示文字消失的示例
  • jQuery 使用prop()函数控制多选框(全选,反选)的简单示例
  • jQuery用iframe来解决跨域的简单示例(1)
  • jquery 实现在同一页面跳转到指定位置的方法
  • js+jQuery 实现页面跳转的方法
  • jquery 获取子节点及当前节点属性值的简单示例
  • jQuery UI改写Accordion,实现同时展开多个Panel
  • 最新文章
    • jQuery end()函数用法示例
    • jQuery stop()方法使用示例
    • jQuery 检查某个元素是否存在的简单示例
    • jQuery 绑定事件的四种简单示例
    • jquery 图片放大实现方法
    • jquery 模拟多级复选框的简单示例
    • jquery 可拖拽窗体实现方法
    • jQuery 动态加载脚本文件的两种示例
    • jquery定时器的简单示例
    • Js动态添加复选框Checkbox的简单示例

四海网收集整理一些常用的php代码,JS代码,数据库mysql等技术文章。