以下是一个示例代码,展示如何使用 Bootstrap 创建一个简单的表格:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bootstrap Table Example</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<h1>Bootstrap Table Example</h1>
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>John Doe</td>
<td>johndoe@example.com</td>
</tr>
<tr>
<td>2</td>
<td>Jane Smith</td>
<td>janesmith@example.com</td>
</tr>
<tr>
<td>3</td>
<td>Mike Johnson</td>
<td>mikejohnson@example.com</td>
</tr>
</tbody>
</table>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
在这个示例中,我们使用了 Bootstrap 的表格样式类(table
和 table-striped
)来创建一个带有斑马纹的表格。通过简单地应用这些类,可以使表格具有漂亮的外观和响应式设计。