搜索这个函数:
Modal.prototype.adjustDialog
修改为
Modal.prototype.adjustDialog = function () {
var modalIsOverflowing = this.$element[0].scrollHeight > document.documentElement.clientHeight
this.$element.css({
paddingLeft: !this.bodyIsOverflowing && modalIsOverflowing ? this.scrollbarWidth : '',
paddingRight: this.bodyIsOverflowing && !modalIsOverflowing ? this.scrollbarWidth : ''
})
//添加的代码
var $modal_dialog = $(this.$element[0]).find('.modal-dialog');
var m_top = ( $(document).height() - $modal_dialog.height() )/2;
$modal_dialog.css({'margin':m_top + 'px auto'});
}
是不是很简单
转载请注明:有爱前端 » bootstrap modal 模态框 垂直居中
