Bootstrap模式:背景跳转到顶部切换 [英] Bootstrap modal: background jumps to top on toggle

查看:82
本文介绍了Bootstrap模式:背景跳转到顶部切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,有一个模态。我在一个页面上有一个按钮,切换模态。当模态显示时,页面跳转到顶部。



我已经做了一切我可以找到一个解决方案/ etc,但我真的迷路了。

编辑:



我也尝试过: $ #myModal').modal('show'); 但它有完全相同的效果。

解决方案

p>当模态打开时, modal-open 类设置为< body> 标记。这个类将 overflow:hidden; 设置到正文。将此规则添加到样式表以覆盖bootstrap.css样式:

  body.modal-open {
overflow:可见;
}

现在滚动应该保持原位。


I have a problem, with a modal. I have a button on a page, that toggles the modal. When the modal shows up, the page jumps to top.

I have done everything I could to find a solution/etc, but I am really lost.

EDIT:

I have also tried with: $('#myModal').modal('show'); but it has the exact same effect.

解决方案

When the modal opens a modal-open class is set to the <body> tag. This class sets overflow: hidden; to the body. Add this rule to your stylesheet to override the bootstrap.css style:

body.modal-open {
    overflow: visible;
}

Now the scroll should stay in place.

这篇关于Bootstrap模式:背景跳转到顶部切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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