码迷,mamicode.com
首页 > 其他好文 > 详细

bootstrap 3.3 模态框垂直居中问题

时间:2015-03-04 19:37:44      阅读:338      评论:0      收藏:0      [点我收藏+]

标签:

/* center modal */
function centerModals(){
    $(‘.modal‘).each(function(i){
        var $clone = $(this).clone().css(‘display‘, ‘block‘).appendTo(‘body‘);    var top = Math.round(($clone.height() - $clone.find(‘.modal-content‘).height()) / 2);
        top = top > 0 ? top : 0;
        $clone.remove();
        $(this).find(‘.modal-content‘).css("margin-top", top);
    });
}
$(‘.modal‘).on(‘show.bs.modal‘, centerModals);
$(window).on(‘resize‘, centerModals);

bootstrap 3.3 模态框垂直居中问题

标签:

原文地址:http://my.oschina.net/daoinfo/blog/382611

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!