leo*_*ora 6 jquery blockui jquery-blockui
我正在使用jquery blockui但是被覆盖的div很长,因此加载消息显示在屏幕上.
反正有没有jquery blockui加载消息垂直居中在可见屏幕上,这样人们可以看到消息而不向下滚动?
这是肯定的答案.
创建此功能:
$.fn.center = function () {
this.css("position","absolute");
this.css("top", ($(window).height() - this.height()) / 2+$(window).scrollTop() + "px");
this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
return this;
}
调用blockUI后,将对话框窗口居中,如下所示:
$('.blockUI.blockMsg').center();
轻松居中显示在屏幕中:
$.blockUI({
message: myMessage,
centerY: false,
centerX: false,
css:{
position: 'fixed',
margin: 'auto'
}
});
Run Code Online (Sandbox Code Playgroud)
blockUI默认显示在屏幕中央。我相信即使您不断滚动页面它也会显示在中心。
但是,您可以在调用时设置以下属性blockUI。
centerX: true
centerY: true
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11979 次 |
| 最近记录: |