[英]Hiding and showing bootstrap 4 modal at the same time will hide the browser's scrollbar
[英]Bootstrap Modal Hiding the Scrollbar
我正在使用Bootstrap v3.3.5。 每次触发模式框时,滚动条都会隐藏,从而使网页变得混乱。 您能给我建议一个解决办法吗?
URL: http : //goo.gl/kwn7YH该模式由右侧的“查询”按钮触发。 我尝试添加cutsom JS来删除边距/填充,但是没有用:
$(document).on( 'hidden.bs.modal', '.modal', function() {
$(document.body).removeClass( 'modal-scrollbar' );
}).on( 'show.bs.modal', '.modal', function() {
// Bootstrap's .modal-open class hides any scrollbar on the body,
// so if there IS a scrollbar on the body at modal open time, then
// add a right margin to take its place.
if ( $(window).height() < $(document).height() ) {
$(document.body).addClass( 'modal-scrollbar' );
}
});
})(window.jQuery);
});
尝试使用$('#myModal').hasClass('in');
然后在按钮处于活动状态时在其右侧应用17px填充。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.