窗口和对话框居中对齐
2015-11-05 10:55
169 查看
Web前端的窗口,对话框等界面,经常需要居中对齐。
在Jquery Easyui中等window组件中,通常有宽度width、高度height、距离容器左边的距离left、距离容器顶部的距离top,4个参数。
在实现过程中,主要就是动态或静态设置这4个参数。
当前窗口的高度:$(window).width()
当前窗口的宽度:$(window).width()
如果是获得父窗口的,用window.parent就可以了。
width:是个方法,不是属性。
下面是一个例子:
var windowWidth =$(window.parent).width();
var windowHeight=$(window.parent).height();
var width=380;
var height=windowHeight-200;
var top=(windowHeight-height)/2;
var left=(windowWidth-width)/2;
var $win = $('#preView').window({
content : '<iframe scrolling="yes" frameborder="0" src="'
+ href
+ '" style="width:100%;height:98%;"></iframe>',
title: 'APP预览',
width: width,
height: height,
top: top,
left: left,
});
$win.window('open');
宽度:固定宽度380
高度:窗口高度-固定200
距离顶部的距离:(窗口高度-对话框的高度)/2,居中对齐
距离左边的距离:居中对齐
在2种屏幕,试了,没有问题~
在Jquery Easyui中等window组件中,通常有宽度width、高度height、距离容器左边的距离left、距离容器顶部的距离top,4个参数。
在实现过程中,主要就是动态或静态设置这4个参数。
当前窗口的高度:$(window).width()
当前窗口的宽度:$(window).width()
如果是获得父窗口的,用window.parent就可以了。
width:是个方法,不是属性。
下面是一个例子:
var windowWidth =$(window.parent).width();
var windowHeight=$(window.parent).height();
var width=380;
var height=windowHeight-200;
var top=(windowHeight-height)/2;
var left=(windowWidth-width)/2;
var $win = $('#preView').window({
content : '<iframe scrolling="yes" frameborder="0" src="'
+ href
+ '" style="width:100%;height:98%;"></iframe>',
title: 'APP预览',
width: width,
height: height,
top: top,
left: left,
});
$win.window('open');
宽度:固定宽度380
高度:窗口高度-固定200
距离顶部的距离:(窗口高度-对话框的高度)/2,居中对齐
距离左边的距离:居中对齐
在2种屏幕,试了,没有问题~
相关文章推荐
- 邂逅StringIndexOutOfBoundsException
- 学习资料
- 遇到的问题汇总
- iOS开发中乱用hook可能导致灾难
- IDL绘制黑体辐射曲线
- SQL查询~ 存在一个表而不在另一个表中的数据
- selenium2-框架思想介绍
- searchResultsTableView的contentSize有问题
- codeforces 590C(bfs)
- Java 编程下的同步代码块
- Http请求分析
- java.lang.UnsupportedClassVersionError 解决办法
- VC 运行时库 /MD、/MDd 和 /MT、/MTd
- 通知开启状态判断
- iOS-- 键盘next 和 点击 Btn
- checkbox 文字不显示
- 构建Mysql三部曲之三 主从案例
- sprintf 实例
- Go编译问题集锦
- mac常用快捷方式