Bootstrap模式被推向右侧

时间:2014-02-20 08:18:24

标签: twitter-bootstrap ruby-on-rails-4 modal-dialog

在rails 4 app中使用Bootstrap 3,我正在调用一个模态:

  <a href="#myModal" data-target="#myModal" role="button" data-toggle="modal"><span class="glyphicon glyphicon-plus"></span> New Listing</a>

    <!-- Modal -->
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h4 class="modal-title" id="myModalLabel">Hey, wait a second!</h4>
          </div>
          <div class="modal-body">
            In order to blah blah...!
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
            <%= link_to "Sign Out", destroy_user_session_path, type: "button" , class: "btn btn-primary" , method: :delete %>
          </div>
        </div><!-- /.modal-content -->
      </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->

一切都运行良好,除非我执行模态,它被推离屏幕右侧: enter image description here

我的模态CSS是:

.modal {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1040;
  display: none;
  overflow: auto;
  overflow-y: scroll;
}

我尝试将位置更改为绝对位置,但这并不能解决问题。

任何记录?

1 个答案:

答案 0 :(得分:0)

原来这是一个CSS问题。我正在使用Bootswatch的bootstrap主题。在使用标准引导代码覆盖Bootswatch的模态CSS元素之后,所有内容都已修复。感谢。