- Bulma 教程
- Bulma - 首页
- Bulma - 介绍
- Bulma - 概览
- Bulma - 修饰符
- Bulma - 列
- Bulma - 布局
- Bulma - 表单
- Bulma - 元素
- Bulma - 组件
- Bulma 实用资源
- Bulma - 快速指南
- Bulma - 资源
- Bulma - 讨论
Bulma - 表格
说明
Bulma 在一个表格格式中封装了显示数据的元素。您需要将 table 的基本类添加到具有以下表格元素的表中 -
| 序号 | 标记和说明 |
|---|---|
| 1 | <table> 这是一个主容器,封装了用于以表格格式显示数据的元素。 |
| 2 | <thead> 这是表格的头部分,包含表的标题行的元素。 |
| 3 | <tbody> 它包含表格体中表格行 (<tr>) 的元素。 |
| 4 | <tr> 它指定出现在一行上的表格单元 (<td> 或 <th>)。 |
| 5 | <th> 它定义表格单元的标题。 |
| 6 | <td> 这是一个默认表格单元。 |
| 7 | <tfoot> 这是表格的底部。 |
基本表格
如果您想在页面中显示基本的表格样式,请将 table 的基本类添加到任何表格中,如下例所示 -
<!DOCTYPE html>
<html>
<head>
<meta charset = "utf-8">
<meta name = "viewport" content = "width = device-width, initial-scale = 1">
<title>Bulma Elements Example</title>
<link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.min.css">
<script src = "https://use.fontawesome.com/releases/v5.1.0/js/all.js"></script>
</head>
<body>
<section class = "section">
<div class = "container">
<span class = "is-size-5">
Basic Table
</span>
<br>
<table class = "table">
<thead>
<tr>
<th>Position</th>
<th>Name</th>
<th>Country</th>
</tr>
</thead>
<tfoot>
<tr>
<th><abbr title = "Position">Pos</abbr></th>
<th>Player</th>
<th>
<abbr title = "Played for the country">Country</abbr>
</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>1</td>
<td>Sachin</td>
<td>India</td>
</tr>
<tr>
<td>2</td>
<td>Smith</td>
<td>Australia</td>
</tr>
<tr>
<td>3</td>
<td>Joe Root</td>
<td>England</td>
</tr>
</tbody>
</table>
</div>
</section>
</body>
</html>
它显示了下例输出 -
修饰符
Bulma 支持以下修饰符以显示不同样式的表格。
is-bordered
is-striped
is-narrow
is-hoverable
is-fullwidth
我们将会采用上述示例,并使用所需的修饰符以及 .table 类。这里,我们将看到在表格中使用 is-bordered 修饰符,如下所示。
<!DOCTYPE html>
<html>
<head>
<meta charset = "utf-8">
<meta name = "viewport" content = "width = device-width, initial-scale = 1">
<title>Bulma Elements Example</title>
<link rel = "stylesheet" href = "https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.min.css">
<script src = "https://use.fontawesome.com/releases/v5.1.0/js/all.js"></script>
</head>
<body>
<section class = "section">
<div class = "container">
<span class = "is-size-5">
Bordered Table
</span>
<br>
<table class = "table is-bordered">
<thead>
<tr>
<th>Position</th>
<th>Name</th>
<th>Country</th>
</tr>
</thead>
<tfoot>
<tr>
<th>
<abbr title = "Position">Pos</abbr>
</th>
<th>Player</th>
<th>
<abbr title = "Played for the country">Country</abbr>
</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>1</td>
<td>Sachin</td>
<td>India</td>
</tr>
<tr>
<td>2</td>
<td>Smith</td>
<td>Australia</td>
</tr>
<tr>
<td>3</td>
<td>Joe Root</td>
<td>England</td>
</tr>
</tbody>
</table>
</div>
</section>
</body>
</html>
它显示了下例输出 -
要使用其他修饰符,只需将表格中上述使用的修饰符替换为其他修饰符。
bulma_elements.htm
广告