【原创】相对完美的垂直居中popup(modal/dialog),无需监听window.resize事件
2015-07-31 15:38
531 查看
<table class="popup" style="position: absolute; background-color: black; border-radius: 10px; top: 50%; left: 50%;"> <tr> <td> <div> <textarea style="margin:10px; background-color:azure; height:150px;width:100px;" contenteditable="true"></textarea> </div> </td> </tr> </table>
$(function () { var $popup = $('.popup'); $popup.css({marginLeft: $popup.width() / 2 * -1 + 'px', marginTop: $popup.height() / 2 * -1 + 'px' }); });
使用table的目的是,模拟弹窗的高度会根据弹窗的内容高度显示。
相关文章推荐
- linux登陆之后显示bash-3.00$
- nginx虚拟目录配置
- 手动编译安装LAMP架构,并且实现nagios图形化监控(八)
- 第一次用IIS发布网站时遇到的两个问题
- OpenWrt配置绿联的usb转Ethernet网口驱动
- nginx的worker进程挂起且某个CPU负载达到100%
- HDU 5336 - XYZ and Drops(暴力模拟)
- centos7环境qemu安装简要介绍
- SOA平台架构解析
- MFC+OpenGL添加WM_DESTROY的消息处理函数Ondestroy( )后出现的错误
- VS2010配置OpenCV
- [转]SELinux管理与配置
- 7-30 添加一个“商品类型维护”的注意事项(接上篇)
- Docker学习之——Node.js+MongoDB+Nginx环境搭建(一)
- CentOS6及7下端口开启与关闭
- VC2005从开发MFC ActiveX ocx控件到发布到.net网站的全部过程
- linux 远程桌面连接
- linux shell 之函数
- Windows及Linux平台下的计时函数总结
- IntelliJ idea 14 集成 tomcat 7