6.5.5 紧凑型表格

6.5.5 紧凑型表格

为指定class="table"的表格增加一个.table-condensed样式即可实现紧凑型表格。紧凑型表格将单元格的padding减半让表格内容更加紧凑。

程序示例

例如如下代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<!DOCTYPE html>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title> 紧凑型表格 </title>
<link rel="stylesheet" href="../bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="../bootstrap/css/bootstrap-theme.min.css">
</head>

<body>
<div class="container">
<table class="table table-condensed">
<caption>
<b>疯狂Java体系图书</b>
</caption>
<thead>
<tr>
<th>书名</th>
<th>作者</th>
<th>价格</th>
</tr>
</thead>
<tbody>
<tr>
<td>疯狂Java讲义</td>
<td>李刚</td>
<td>109</td>
</tr>
<tr>
<td>疯狂HTML 5/CSS 3/JavaScript讲义</td>
<td>李刚</td>
<td>79</td>
</tr>
<tr>
<td>疯狂前端开发讲义</td>
<td>李刚</td>
<td>79</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="3" style="text-align:right">现总计:3本图书</td>
</tr>
</tfoot>
</table>
</div>
<script type="text/javascript" src="../jquery-3.1.1.js"></script>
<script type="text/javascript" src="../bootstrap/js/bootstrap.min.js"></script>
</body>

</html>