首页 > 解决方案 > 在 Bootstrap 模式中调整表格内容的大小

问题描述

我使用 Bootstrap 制作了一个简单的模式,以允许用户查看表格内容。但是,我在尝试将表格内容保留在模式中时遇到问题。

当我减小网站/模态的大小时,表格内容将超出模态。有什么办法可以让用户滚动以便他们可以看到里面的所有表格内容?

这是我的JSFiddle代码:

<button type="button" class="btn btn-default" data-toggle="modal" data-target="#complex">Button</button>
<div class="modal fade" id="complex" tabindex="-1" role="dialog">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title" id="myModalLabel">Test</h4>
      </div>
      <div class="modal-body">
        <table id="example" class="table">
          <thead>
            <tr>
              <th>First Name</th>
              <th>Last Name</th>
              <th>ID Number</th>
              <th>Proband</th>
              <th>Gender</th>
              <th>Birth Date</th>
              <th>Life Status</th>
              <th>Phenotype</th>
              <th>Genotype</th>
              <th>&nbsp;</th>
            </tr>
          </thead>
        </table>
      </div>
    </div>
  </div>
</div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

标签: javascripthtmlcsstwitter-bootstrap

解决方案


如果你想在你的模态容器上滚动,那么你只能使用 css。在这里寻找小提琴:http: //jsfiddle.net/oq0xLmz2/

.modal-body {
    overflow : auto;
}

推荐阅读