Bulma - 表格
描述
Bulma 包装元素以表格格式显示数据。您需要将 .table 类的基类添加到带有以下表格元素的 <table> −
Sr.No | 标签 &描述 |
---|---|
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>
它显示以下输出 −
要使用其他修饰符,只需将上面使用的修饰符替换为表中的其他修饰符即可。