HTML表格不适合引导程序面板

时间:2016-02-26 16:02:18

标签: twitter-bootstrap html-table panel

我正在尝试将一个数据表放在一个手风琴部分的自举面板中。然而,桌子一直在面板外溢出......有人可以帮忙吗?这是我的代码:

<div class="container">
<div class="myaccordion">
    <div class="panel-group" id="accordion">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h4 class="panel-title">
                    <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">Section One</a>
                </h4>
            </div>
            <div id="collapseOne" class="panel-collapse collapse in">
                <div class="panel-body">
                    <div class="row"><!-- company orders -->
                      <div class="container">
                        <h3>{{context.company.company_name}}'s Orders</h3>
                        <table id="company_orders" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">
                              <thead>
                                  <tr>
                                    <th>Order Date</th>
                                      <th>Order ID</th>
                                      <th>PO #</th>
                                      <th>Order Total ($)</th>
                                      <th>Status</th>
                                      <th></th>
                                  </tr>
                              </thead>
                              <tbody>
                                  {{#each context.order}}
                                  <tr>
                                    <td class="order_date">{{order_date}}</td>
                                      <td class="order_id">{{order_id}}</td>
                                      <td class="po_num">{{po_num}}</td>
                                      <td class="order_total">{{order_total}}</td>
                                      <td class="price">{{order_status}}</td>
                                      <th><a href="/admin/{{order_id}}">View Details</a></th>
                                  </tr>
                                  {{/each}}
                              </tbody>
                          </table>
                      </div>
                    </div><!-- company orders end -->
                </div>
            </div>
        </div>
    </div>
</div>

Image showing table overflow on the right side

1 个答案:

答案 0 :(得分:1)

这是因为您在container中嵌套了container。你不能在Bootstrap中做到这一点。只需在row内使用panel-body,在行后使用col-md-12类。

<div class="container">
  <div class="myaccordion">
    <div class="panel-group" id="accordion">
      <div class="panel panel-default">
        <div class="panel-heading">
          <h4 class="panel-title">
                <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">Section One</a>
            </h4>
    </div>
    <div id="collapseOne" class="panel-collapse collapse in">
      <div class="panel-body">
        <div class="row">
          <!-- company orders -->
          <div class="col-md-12">
            <h3>{{context.company.company_name}}'s Orders</h3>
            <table id="company_orders" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">
              <thead>
                <tr>
                  <th>Order Date</th>
                  <th>Order ID</th>
                  <th>PO #</th>
                  <th>Order Total ($)</th>
                  <th>Status</th>
                  <th></th>
                </tr>
              </thead>
              <tbody>
                {{#each context.order}}
                <tr>
                  <td class="order_date">{{order_date}}</td>
                  <td class="order_id">{{order_id}}</td>
                  <td class="po_num">{{po_num}}</td>
                  <td class="order_total">{{order_total}}</td>
                  <td class="price">{{order_status}}</td>
                  <th><a href="/admin/{{order_id}}">View Details</a></th>
                </tr>
                {{/each}}
              </tbody>
            </table>
          </div>
        </div>
        <!-- company orders end -->
      </div>
    </div>
  </div>
</div>

CODEPEN