在移动浏览器上打开 Bootstrap 3 模式时如何防止背景滚动? [英] How to prevent background scrolling when Bootstrap 3 modal open on mobile browsers?

查看:30
本文介绍了在移动浏览器上打开 Bootstrap 3 模式时如何防止背景滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在移动平台上打开 Bootstrap 3 模式时如何防止背景滚动?在桌面浏览器上,背景无法滚动并正常工作.

How to prevent background scrolling when Bootstrap 3 modal open on mobile platforms? On desktop browsers the background is prevented from scrolling and works as it should.

在移动浏览器(Safari ios、Chrome ios 等)上,当打开模态并使用手指滚动它时,背景也会像模态一样滚动.我该如何预防?

On mobile browsers (Safari ios, Chrome ios, etc), when a modal is opened and using your finger to scroll it, the background also scrolls as does the modal. How do I prevent that?

推荐答案

见这里:https://github.com/twbs/bootstrap/issues/7501

那就试试吧:

$('body').css('overflow','hidden');
$('body').css('position','fixed');

V3.0.0.应该解决了这个问题.你用的是最新版本吗?如果是这样,请在 https://github.com/twbs/bootstrap/

V3.0.0. should have fixed this issue. Do you use the latest version? If so post an issue on https://github.com/twbs/bootstrap/

这篇关于在移动浏览器上打开 Bootstrap 3 模式时如何防止背景滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆