使用Bootstrap 5的表格类和表格底部类。以下是一个完整的HTML示例代码,其中包含带边框的表格底部:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Bootstrap Table Example</title>
<!--引入Bootstrap CSS-->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0/dist/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<h1>Example Table</h1>
<table class="table table-bordered">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
<th>Phone</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>John</td>
<td>john@example.com</td>
<td>555-1234</td>
</tr>
<tr>
<td>2</td>
<td>Bob</td>
<td>bob@example.com</td>
<td>555-5555</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="4">Total: 2</td>
</tr>
</tfoot>
</table>
</div>
<!--引入Bootstrap JavaScript-->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
在上面的代码中,我们创建了一个包含一个带边框的表格的容器。表格的类设置为“table table-bordered”。
在表格的thead部分,我们定义了表格的列标题。在表格的tbody部分,我们添加了两个数据行。
在表格的tfoot部分,我们添加了一个单元格,其中包含一个合并了所有列的单元格。使用colspan属性将单元格合并成一个单元格,并在其中添加表格底部内容。表格底部的类设置为“table-dark”。
最后,我们在页面底部引入Bootstrap 5的JavaScript文件,以确保页面上的所有Bootstrap组件都能正常工作。
总之,使用Bootstrap 5可以轻松创建带边框的表格底部,从而使表格更具吸引力和可读性。
正文完