2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > bootstrap modal模态框垂直居中

bootstrap modal模态框垂直居中

时间:2024-06-14 16:16:09

相关推荐

bootstrap modal模态框垂直居中

直接修改bootstrap.js 源码:

弹出框出现时, 调用的是 Modal.prototype.show() 方法, 而show 方法中又调用了that.adjustDialog() 方法:

Modal.prototype.adjustDialog = function () {var modalIsOverflowing = this.$element[0].scrollHeight > document.documentElement.clientHeightthis.$element.css({paddingLeft: !this.bodyIsOverflowing && modalIsOverflowing ? this.scrollbarWidth : '',paddingRight: this.bodyIsOverflowing && !modalIsOverflowing ? this.scrollbarWidth : ''})}

修改:

Modal.prototype.adjustDialog = function () {var modalIsOverflowing = this.$element[0].scrollHeight > document.documentElement.clientHeightthis.$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 = ( $(window).height() - $modal_dialog.height() )/2;$modal_dialog.css({'margin': m_top + 'px auto'});}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。