HTML table 不适合 bootstrap 面板
HTML table won't fit inside of bootstrap panel
我正在尝试将数据table 放入手风琴的 bootstrap 面板中。但是,table 一直溢出到面板之外……有人可以帮忙吗?这是我的代码:
<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>
这是因为您在 container
中嵌套了 container
。你不能在 Bootstrap 中这样做。只需在 panel-body
内使用 row
并在行后使用 col-md-12
class。
<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>
我正在尝试将数据table 放入手风琴的 bootstrap 面板中。但是,table 一直溢出到面板之外……有人可以帮忙吗?这是我的代码:
<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>
这是因为您在 container
中嵌套了 container
。你不能在 Bootstrap 中这样做。只需在 panel-body
内使用 row
并在行后使用 col-md-12
class。
<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>