我有一个长模态,它不能完全显示在我的android移动设备上,按钮在屏幕底部下方,模态根本不会滚动,但模态后面的灰色背景会滚动,有什么css/js技巧可以锁定背景并允许模态在显示时滚动吗?
这可能是因为模态类的位置是固定的。。。试着把下面的代码放在你的css文件中,这对我来说是有效的…
@media (max-width: 767px) {
.modal {
position: absolute;
overflow:visible;
}
.modal-open {
overflow:visible;
}
}
这是应该用Bootstrap 3修复的,但它对我不起作用。我可以通过-webkit溢出滚动CSS属性和设置模式的最大高度来修复它。由于我想让我的modal填满整个屏幕,我不得不连接一些javascript来检测移动设备,并将.modal内容的最大高度设置为设备的视口高度
以下是我使用一个名为jRespond:的库来解决这个问题的方法
将此CSS添加到您的模式
@media (max-width: $screen-xs-max) {
.modal-dialog {
.modal-content {
-webkit-overflow-scrolling: touch;
overflow-y: auto;
}
}
}
将jRespond添加到您的应用程序
https://github.com/ten1seven/jRespond/edit/master/js/jRespond.js
将以下代码添加到main.js脚本
/* This code handles the responsive modal for mobile */
var jRes = jRespond([{
label: 'handheld',
enter: 0,
exit: 767
}]);
jRes.addFunc({
breakpoint: 'handheld',
enter: function() {
$('.modal-content').css('max-height', $(window).height());
$(window).on('orientationchange', function () {
$('.modal-content').css('max-height', $(window).height());
});
},
exit: function () {
$('.modal-content').css('max-height', "");
$(window).off('orientationchange');
}
});