设置居中
来源:互联网 发布:chrome 全屏 mac 编辑:程序博客网 时间:2024/05/01 00:52
function setDivCenter(obj){
//Dialog对象宽高
var objwh = {w:0,h:0};
objwh.h = $(obj).height();
objwh.w = $(obj).width();
//Window宽高
var winwh = {w:0,h:0};
winwh.h = getWindowHeight();
winwh.w = getWindowWidth();
//当前滚动到的位置
var scrollPos = {t:0,l:0};
scrollPos.t = $(document).scrollTop();
scrollPos.l = $(document).scrollLeft();
//Dialog显示位置
var position = {t:0,l:0};
position.t = scrollPos.t+((winwh.h-objwh.h)/2);
position.l = scrollPos.l+((winwh.w-objwh.w)/2);
position.t = position.t<=0?0:position.t;
position.l = position.l<=0?0:position.l;
//移动Dialog居中
$(obj).css("top",position.t);
$(obj).css("left",position.l);
$(obj).css("height","auto");
//内部函数
//获取浏览器高
function getWindowHeight(){
if($.browser.msie){
return document.compatMode == "CSS1Compat"? document.documentElement.clientHeight :
document.body.clientHeight;
}else{
return self.innerHeight;
}
}
//获取浏览器宽
function getWindowWidth (){
if($.browser.msie){
return document.compatMode == "CSS1Compat"? document.documentElement.clientWidth :
document.body.clientWidth;
}else{
return self.innerWidth;
}
}
}
- 设置居中
- 设置居中
- swt设置窗体居中
- swt设置窗体居中
- 设置窗口居中显示
- 设置页面居中
- 设置TextView文字居中
- 设置TextView文字居中
- 设置TextView文字居中
- 设置字体垂直居中
- CSS设置DIV居中
- DataGirdView 设置单元格居中
- 设置TextView文字居中
- Hbox设置居中
- 设置TextView文字居中
- DIV设置位置居中
- 居中的设置
- 设置TextView文字居中
- Using windows live writer to write my blog
- 卡皇10G
- Java静态变量的初始化(static块的本质)
- 内核对象(2)
- 创建文件夹
- 设置居中
- ORACLE ERP
- 在Spring框架下获取Bean的方式总结(转)
- HibernateTemplate 的 两个 execute 方法区别
- 关于Struts2的默认选中值的解决方法
- struts2标签和ongl表达式结合表示&&和||的写法
- 用随机乱序建造理想的密钥数组
- struts2性能优化
- struts2中session的使用