提问人:user1045680 提问时间:11/13/2023 更新时间:11/13/2023 访问量:21
将 scroll-y 添加到 jquer 数据表中溢出的单元格并限制行高
Add scroll-y to a cell that overflows in jquer datatables and limit row height
问:
我有一个 django 网站,它使用 jquery datatables 来显示一个包含 13 个值的表。前 12 个值是几个单词或数字。最后一列有很多单词。我想在最后一列添加一个垂直滚动条,并将每行的高度限制为 2 行文本,以便表格更紧凑。
但是,如果我使浏览器窗口变小,模拟较小的屏幕,由于最后一列中的所有文本,我会得到巨大的行。
我愿意接受关于如何使表格在较小屏幕(包括手机)上看起来更好的其他建议。
表格的 html:
{% for f in flights %}
<div class="row mt-4">
<div class="col-12">
<div class="card mb-4">
<div class="card-header pb-0">
<p class="mb-1 pt-2 text-bold">{{ f.date }}</p>
<h5 class="font-weight-bolder">{{ f.teacher_name }}</h5>
</div>
<div class="card-body px-0 pt-0 pb-2">
<div class="table-responsive p-0">
<table class="display" id="models" style="width:100%">
<thead>
<tr class="text-center mb-0 text-lg font-weight-bold">
<th rowspan="2">Rocket Name</th>
<th rowspan="2">Mission Specialists</th>
<th rowspan="2">Flight Engineers</th>
<th rowspan="2">Type</th>
<th colspan="1">Lift-off Weight</th>
<th colspan="2">Altitude</th>
<th rowspan="2">Egg</th>
<th rowspan="2">Shockcord</th>
<th rowspan="2">Nose cone</th>
<th rowspan="2">Coupler</th>
<th rowspan="2">Parachute</th>
<th rowspan="2">Notes</th>
</tr>
<tr class="text-center mb-0 text-lg font-weight-bold">
<th>grams</th>
<th>meters</th>
<th>feet</th>
</tr>
</thead>
<tbody>
{% for flight in f.flight_data %}
<tr>
<td class="text-center mb-0 text-lg font-weight-bold text-nowrap">{{ flight.name }}</td>
<td class="text-center mb-0 text-lg font-weight-bold text-nowrap">{{ flight.mission_specialists }}</td>
<td class="text-center mb-0 text-lg font-weight-bold text-nowrap">{{ flight.flight_engineers }}</td>
<td class="text-center mb-0 text-lg font-weight-bold text-nowrap">{{ flight.rocket_type }}</td>
<td class="text-center mb-0 text-lg font-weight-bold text-nowrap">{{ flight.weight|format_zero|format_data:1|units:'g' }}</td>
<td class="text-center mb-0 text-lg font-weight-bold text-nowrap">{{ flight.altitude_m|format_zero|format_data:1|units:'m' }}</td>
<td class="text-center mb-0 text-lg font-weight-bold text-nowrap">{{ flight.altitude_f|format_zero|format_data:1|units:'ft' }}</td>
<td class="text-center mb-0 text-lg font-weight-bold text-nowrap">{{ flight.egg }}</td>
<td class="text-center mb-0 text-lg font-weight-bold text-nowrap">{{ flight.shockcord }}</td>
<td class="text-center mb-0 text-lg font-weight-bold text-nowrap">{{ flight.nose_cone }}</td>
<td class="text-center mb-0 text-lg font-weight-bold text-nowrap">{{ flight.coupler }}</td>
<td class="text-center mb-0 text-lg font-weight-bold text-nowrap">{{ flight.parachute }}</td>
<td class="mb-0 text-lg font-weight-bold">{{ flight.notes|safe }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
{% endfor %}
答: 暂无答案
评论
class='text-truncate' style='max-width: 150px;'
View notes