bootstrap 模态框垂直居中
2016-12-06 11:04
357 查看
1 /** 2 * 使页面中所有.modal元素在窗口可视范围之内居中 3 **/ 4 function centerModals(){ 5 $('.modal').each(function(i){ 6 var $clone = $(this).clone().css('display', 'block').appendTo('body'); 7 var top = Math.round(($clone.height() - $clone.find('.modal-content').height()) / 2); 8 top = top > 50 ? top : 0; 9 $clone.remove(); 10 $(this).find('.modal-content').css("margin-top", top-50); 11 }); 12 } 13 // 在模态框出现的时候调用垂直居中函数 14 $('.modal').on('show.bs.modal', centerModals); 15 // 在窗口大小改变的时候调用垂直居中函数 16 $(window).on('resize', centerModals);
相关文章推荐
- Bootstrap modal 模态框垂直居中
- Bootstrap模态窗- 垂直居中 & 拖动
- 通过纯css样式将bootstrap模态框垂直居中
- BootStrap模态框不垂直居中的解决方法
- Bootstrap模态框(modal)垂直居中
- bootstrap 模态框(modal)实现水平垂直居中显示 含具体分析
- bootstrap 模态框垂直居中实现方法
- bootstrap 模态框(modal)实现水平垂直居中显示的方法
- Bootstrap模态框(modal)垂直居中
- bootstrap多个modal模态框同时设置垂直居中的方法
- Bootstrap 模态框垂直居中
- bootstrap 3.3 模态框垂直居中问题
- Bootstrap模态框水平垂直居中
- Bootstrap模态框(modal)垂直居中
- Bootstrap(v3.2.0)模态框(modal)垂直居中
- Bootstrap 模态框垂直居中处理
- bootstrap模态框 垂直居中
- Bootstrap模态框如何垂直居中?
- BootStrap3.X模态框垂直居中显示
- bootstrap 模态框(modal)实现水平垂直居中显示