Bre*_*ogt 46 html css html5 twitter-bootstrap twitter-bootstrap-3
如何在Bootstrap响应表中设置列的大小?我不希望桌子失去它的反复功能.我也需要它在IE8中工作.我已经包含了HTML5SHIV和Respond.
我正在使用Bootstrap 3(3.2.0)
<div class="table-responsive">
<table id="productSizes" class="table">
<thead>
<tr>
<th>Size</th>
<th>Bust</th>
<th>Waist</th>
<th>Hips</th>
</tr>
</thead>
<tbody>
<tr>
<td>6</td>
<td>79 - 81</td>
<td>61 - 63</td>
<td>89 - 91</td>
</tr>
<tr>
<td>8</td>
<td>84 - 86</td>
<td>66 - 68</td>
<td>94 - 96</td>
</tr>
</tbody>
</table>
</div>
Run Code Online (Sandbox Code Playgroud)
Jor*_*J.D 101
Bootstrap 4.0
请注意从Bootstrap 3到4 的所有迁移更改.在表中,您现在需要通过添加类来启用弹性框d-flex,并放下xs以允许引导程序自动检测视口.
<div class="container-fluid">
<table id="productSizes" class="table">
<thead>
<tr class="d-flex">
<th class="col-1">Size</th>
<th class="col-3">Bust</th>
<th class="col-3">Waist</th>
<th class="col-5">Hips</th>
</tr>
</thead>
<tbody>
<tr class="d-flex">
<td class="col-1">6</td>
<td class="col-3">79 - 81</td>
<td class="col-3">61 - 63</td>
<td class="col-5">89 - 91</td>
</tr>
<tr class="d-flex">
<td class="col-1">8</td>
<td class="col-3">84 - 86</td>
<td class="col-3">66 - 68</td>
<td class="col-5">94 - 96</td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
Bootstrap 3.2
表列宽度使用与网格相同的布局; 使用col-[viewport]-[size].请记住,列大小应为12; 1 + 3 + 3 + 5 = 12在这个例子中.
<thead>
<tr>
<th class="col-xs-1">Size</th>
<th class="col-xs-3">Bust</th>
<th class="col-xs-3">Waist</th>
<th class="col-xs-5">Hips</th>
</tr>
</thead>
Run Code Online (Sandbox Code Playgroud)
请记住设置<th>元素而不是<td>元素,以便设置整个列.这是一个有效的BOOTPLY.
感谢@Dan提醒我始终首先使用移动视图(col-xs-*).
Dan*_*Dan 17
您可以使用内联样式并在<th>标记中定义宽度.使其宽度的总和= 100%.
<tr>
<th style="width:10%">Size</th>
<th style="width:30%">Bust</th>
<th style="width:50%">Waist</th>
<th style="width:10%">Hips</th>
</tr>
Run Code Online (Sandbox Code Playgroud)
通常使用内联样式并不理想,但这确实提供了灵活性,因为您可以获得具有精确宽度的非常具体和粒度.
小智 6
您可以使用以下 Bootstrap 类
<tr class="w-25">
</tr>
Run Code Online (Sandbox Code Playgroud)
有关更多详细信息,请查看以下页面 https://getbootstrap.com/docs/4.1/utilities/sizing/
| 归档时间: |
|
| 查看次数: |
156181 次 |
| 最近记录: |