【发布时间】:2021-07-27 12:23:13
【问题描述】:
我对 bootstrap 非常陌生,并且正在扩展一个现有的 MVC Web 应用程序,该应用程序通过添加一个带有表单输入字段的表来使用 bootstrap 4。我想弄清楚如何控制表格列宽。一个下拉列表有很长的选项,所以我希望能够限制该列的大小并溢出/包装下拉列表中的文本,但我很难调整空表的大小。这是页面的现有 div 结构和我放入的虚拟表,其结构与真实表的结构相同。
<div class="form-horizontal col-10 offset-1">
<div class="row">
<h5 class="mt-n1 pl-1">Section title</h5>
</div>
<div class="row" style="background-color:#e8eef4; border: 1px solid #d2d2d2; border-radius: 3px; padding-top: 4px;">
<table class="table table-borderless table-condensed">
<thead>
<tr>
<th class="col-3">Column 1</th>
<th class="col-6">Column 2</th>
<th class="col-3">Column 3</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<select class="form-control">
<option>Select...</option>
<option>Option 1</option>
<option>Option 2</option>
</select>
</td>
<td>
<select class="form-control">
<option>Select...</option>
<option>An example of the really long text for the select option that will need to overflow.</option>
<option>Another example of the really long text for the select option that will need to overflow.</option>
</select>
</td>
<td>
<textarea class="form-control" cols=20 rows=2></textarea>
</td>
</tr>
</tbody>
</table>
</div>
</div>
这无法以我期望的方式控制列宽。我已阅读有关将 container 类添加到其中一个 div 以允许控制列宽的信息,但我不确定将其添加到哪个 div。我还阅读了有关使用 table-responsive 类的信息,但我宁愿没有滚动表。您能提供的任何帮助将不胜感激。
https://codeply.com/v/fT9xOWEToJ
【问题讨论】:
标签: html css bootstrap-4