窗口和对话框居中对齐
2015-11-09 10:47
363 查看
转载自:http://blog.csdn.net/fansunion/article/details/49659783
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种屏幕,试了,没有问题~
版权声明:本文为博主原创文章,未经博主允许不得转载
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种屏幕,试了,没有问题~
版权声明:本文为博主原创文章,未经博主允许不得转载
相关文章推荐
- 配置tomcat,在访问时不需要加端口号和工程名
- Linux下用makepasswd和passwordmaker生成密码
- oracle定时添加或删除分区表的分区
- 二维码的生成
- LeetCode Plus One
- UnKnownHostException
- oracle的查询结果合并
- vc++6.0快捷键
- 程序员眼中的英语单词
- 你会做Web上的用户登录功能吗?
- 慢慢数据抓取路,从BeautifulSoup走起
- Nginx下让SSL支持SPDY协议
- Paint.Join与Paint.Cap
- java源码分析03-InputSteam
- Spring data redis-StringRedisTemplate 用法
- 程序设计——规则
- Kafka笔记--监控系统KafkaOffsetMonitor
- Redis操作的封装类
- 匈牙利算法—解决二分图最大匹配问题
- 侧边导航(高级搜索)应用到 $("xxxxx").click(function () {}点击某控件是触发的方法,