Bootstrap 3.3.7模态打开并跳转到顶部

时间:2018-04-03 16:57:03

标签: css twitter-bootstrap modal-dialog bootstrap-modal

当我在Bootstrap 3.3.7中打开模态时,它跳转到页面顶部。

我正在使用官方CDN的Bootstrap JS 3.3.7

https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js

我已经尝试过像这样的CSS解决方案,但对我不起作用

body.modal-open {
    overflow: visible;
}

这是我生产中的webapp的URL,可以看到Boostrap模式的行为。 My webapp with modal issue

Button with modal problem

1 个答案:

答案 0 :(得分:2)

如果您尝试从模态中删除滚动。这可能是你的解决方案。

你可以对你的模态做些什么

  1. 模态中的内容太多(删除不需要的元素)
  2. 更改填充(使用自定义CSS覆盖写入引导程序css)
  3. 更改textarea的高度。
  4. modal-lg课程添加到your modal-dialog <div>
  5. 例如:<div class="modal-dialog modal-lg" role="document">

    1. 添加了一些示例css,可以帮助您删除滚动。
    2. 最后添加了一个截图,介绍了完成上述所有更改后的效果。

      Bootstrap模型:https://getbootstrap.com/docs/3.3/javascript/#modals

      &#13;
      &#13;
      //Changing the margin of dialog
      .modal-dialog {
          margin: 5px auto;
      }
      
      //removing extra padding from the body
      .modal-body {
          position: relative;
          padding: 0 15px;
      }
      
      // Add padding to your footer
      .modal .modal-footer {
          border-top: none;
          padding: 10px;
      }
      
      // change height of textarea
      textarea.form-control {
          height: 100px !important;
      }
      &#13;
      &#13;
      &#13;

      bootstrap modal with no scroll