html - 容器流体中的引导固定宽度表列
问题描述
我有一个问题问你。我正在尝试在容器流体div 中修复表格列的大小。我曾尝试设置style="width: xx.x%"
,但它会根据单元格内容继续更改。
我也尝试过使用 max-with,但它仍然不起作用。在我的代码下面:
<div class="container-fluid">
<div class="row">
<div class="col-12">
<table class="table table-sm text-nowrap">
<thead>
<tr class="bg-info text-white">
<th style="max-width: 1%">2020</th>
<th style="max-width: 9%">Voci</th>
<th class="text-center" style="max-width: 7.5%">Gen</th>
<th class="text-center" style="max-width: 7.5%">Feb</th>
.......
我希望该列具有固定宽度(广告示例最大值和最小值等于 7.5%)。我怎么能在引导程序中得到这个?
解决方案
您应该使用d-flex
您的财产table
来制作fix width
.
您可以使用col
类来指定每列的宽度。
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-12">
<table id="productSizes" class="table">
<thead>
<tr class="bg-info d-flex">
<th class="col-3">2020</th>
<th class="col-3">Voice</th>
<th class="col-3">Gen</th>
<th class="col-3">Feb</th>
</tr>
</thead>
<tbody>
<tr class="d-flex">
<td class="col-3">First Column with fixed width look at that, it is moving text to next line if it
overflowing</td>
<td class="col-3">Second Column with fixed width</td>
<td class="col-3">Lorem ipsum dolor sit amet consectetur adipisicing elit. Expedita, atque earum
asperiores ex
quod quia mollitia dese</td>
<td class="col-3">This is third clumn</td>
</tr>
<tr class="d-flex">
<td class="col-3">8</td>
<td class="col-3">84 - 86</td>
<td class="col-3">66 - 68</td>
<td class="col-3">94 - 96</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>
推荐阅读
- julia - 为什么 LightGraphs.betweenness_centrality() 运行这么长时间
- ios - UITextView 在调整大小时删除临时空行
- node.js - 为什么我不能在 mongoDB 和 mongoose 中使用 '0' 作为 _id?
- php - 如何在每五次出现另一个字符串后插入字符串?
- c# - 不能隐含隐蔽类型...到
- typescript - 打字稿推断继承类中的方法返回类型
- java - 在 VirtualBox 上运行 OpenDaylight - 错误
- c++ - 将整个标准库链接到每个 C/C++ 文件空间是否有效?
- elasticsearch - 基于 Logstash 内容的过滤,进入多个索引
- python - 为什么我从 python 脚本中得到“psql:服务器意外关闭连接”?