2 回答
TA贡献1820条经验 获得超10个赞
使用.w-auto表上的类:
<table class="table w-auto">
<tr>
<td>AAA:</td>
<td>Some Text A</td>
</tr>
<tr>
<td>B:</td>
<td>Some Text B</td>
</tr>
<tr>
<td>CCCCC:</td>
<td>Some Text C</td>
</tr>
</table>
TA贡献1829条经验 获得超4个赞
普通桌
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<div class="table-responsive">
<table class="table w-auto">
<tr>
<td>AAA:</td>
<td>Some Text A</td>
</tr>
<tr>
<td>B:</td>
<td>Some Text B</td>
</tr>
<tr>
<td>CCCCC:</td>
<td>Some Text C</td>
</tr>
</table>
</div>
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
如果内容不适合屏幕,如何自动换行?就像我给出的例子一样
我建议不要使用下面的代码片段,因为它的编码方式并不温和。
.table tr {
display: flex;
flex-wrap: wrap;
}
.table tr td:last-child {
margin-left: auto;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<div class="table-responsive">
<table class="table w-auto">
<tr>
<td>AAA:</td>
<td>Some Text A</td>
</tr>
<tr>
<td>B:</td>
<td>Some Text B</td>
</tr>
<tr>
<td>CCCCC:</td>
<td>Some Text C</td>
</tr>
</table>
</div>
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
- 2 回答
- 0 关注
- 129 浏览
添加回答
举报