发布时间:2019-09-28作者:laosun阅读(1970)
打开bootstrap.js,搜索 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 : '' }) }
修改成以下,增加了几行
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 = ( $(window).height() - $modal_dialog.height() )/2; $modal_dialog.css({'margin': m_top + 'px auto'}); }
这么简单的修改方式,却没有居中的设置,只能说明国外和国内的审美还是有区别的。
修改完成后,保存退出。 强刷浏览器试试效果吧!
版权属于: 技术客
原文地址: https://www.sunjs.com/article/detail/418f173989df404fbd9f00ab1aa540cc.html
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
关键字: jquery 前端 源码 开源 javascript