Bootstrap模态框水平垂直居中
来源:互联网 发布:bgm制作软件 编辑:程序博客网 时间:2024/05/22 04:30
找了好久, 一直没找到使用纯css的方法, 下面是结合css和js的方法, 欢迎提出更好的方法.
css如下:
/* 覆写自带的样式 */.modal-dialog { position: absolute; top: 50%; left: 50%; z-index: 3; margin: auto; -webkit-transform: translate(-50%, -50%) !important; -moz-transform: translate(-50%, -50%) !important; -ms-transform: translate(-50%, -50%) !important; -o-transform: translate(-50%, -50%) !important; transform: translate(-50%, -50%) !important;}
由于上面的transform在ie8下不能用, 所以才有了下面的js:
$modal.on('shown.bs.modal', function(event) { var ieVersion = getIEVersion(); // 非ie或者ie9+使用css已经可以了 if (ieVersion === false || ieVersion > 8) { return true; } var $modalDialog = $modal.find('.modal-dialog'), h = $modalDialog.height(), w = $modalDialog.width(); $modalDialog.css({ marginLeft: -w / 2, marginTop: -h / 2 });});// 兼容ie9及以下版本function getIEVersion() { var v = 3, div = document.createElement('div'), beacon = div.getElementsByTagName('i'); while ( div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->', beacon[0] ); return v > 4 ? v : false;}
0 0
- Bootstrap模态框水平垂直居中
- Bootstrap模态框水平垂直居中与增加拖拽功能
- Bootstrap模态框水平垂直居中与增加拖拽功能
- Bootstrap 模态框(modal)实现水平垂直居中显示
- Bootstrap表格内容垂直水平居中
- Bootstrap 表格内容水平、垂直居中
- Bootstrap 模态框垂直居中
- bootstrap模态框 垂直居中
- Bootstrap登录框自适应水平居中+垂直居中
- 水平居中,垂直居中
- 水平居中垂直居中
- Bootstrap模态框(modal)垂直居中
- Bootstrap模态框(modal)垂直居中
- Bootstrap modal 模态框垂直居中
- bootstrap模态框(modal)垂直居中
- bootstrap模态框垂直居中效果
- BootStrap模态框垂直居中方法
- Bootstrap 模态框垂直居中处理
- 设置命令行中文显示
- 内核崩溃kdump和crash分析工具
- Thinkphp 实现动态include
- TextView 换行对齐自定义
- 动态规划入门(四)
- Bootstrap模态框水平垂直居中
- 微信开发四 接收事件推送
- 保护模式下的CPL,RPL,DPL与特权级检查(二)
- 浅谈HTTP中Get与Post的区别【转载】
- openstack性能测试【rally】
- 基类去掉标题栏
- C++作业四
- for 循环和 for/in 循环的区别
- 哈密顿绕行世界问题 (HDU