bulma/docs/documentation/elements/table.html

869 lines
19 KiB
HTML
Raw Normal View History

---
2017-07-29 12:02:00 +00:00
title: Table
2024-03-21 16:11:54 +00:00
layout: docs
theme: library
doc-tab: elements
doc-subtab: table
2018-04-09 13:15:31 +00:00
breadcrumb:
2024-03-21 16:11:54 +00:00
- home
- documentation
- elements
- elements-table
2018-04-09 13:15:31 +00:00
meta:
colors: false
sizes: false
variables: true
---
2016-10-30 12:20:51 +00:00
{% capture table_example %}
<table class="table">
<thead>
<tr>
2016-10-30 12:20:51 +00:00
<th><abbr title="Position">Pos</abbr></th>
<th>Team</th>
<th><abbr title="Played">Pld</abbr></th>
<th><abbr title="Won">W</abbr></th>
<th><abbr title="Drawn">D</abbr></th>
<th><abbr title="Lost">L</abbr></th>
<th><abbr title="Goals for">GF</abbr></th>
<th><abbr title="Goals against">GA</abbr></th>
<th><abbr title="Goal difference">GD</abbr></th>
<th><abbr title="Points">Pts</abbr></th>
<th>Qualification or relegation</th>
</tr>
</thead>
<tfoot>
<tr>
2016-10-30 12:20:51 +00:00
<th><abbr title="Position">Pos</abbr></th>
<th>Team</th>
<th><abbr title="Played">Pld</abbr></th>
<th><abbr title="Won">W</abbr></th>
<th><abbr title="Drawn">D</abbr></th>
<th><abbr title="Lost">L</abbr></th>
<th><abbr title="Goals for">GF</abbr></th>
<th><abbr title="Goals against">GA</abbr></th>
<th><abbr title="Goal difference">GD</abbr></th>
<th><abbr title="Points">Pts</abbr></th>
<th>Qualification or relegation</th>
</tr>
</tfoot>
<tbody>
<tr>
2016-10-30 12:20:51 +00:00
<th>1</th>
2024-03-21 16:11:54 +00:00
<td>
<a
href="https://en.wikipedia.org/wiki/Leicester_City_F.C."
title="Leicester City F.C."
>Leicester City</a
>
<strong>(C)</strong>
</td>
2016-10-30 12:20:51 +00:00
<td>38</td>
<td>23</td>
<td>12</td>
<td>3</td>
<td>68</td>
<td>36</td>
<td>+32</td>
<td>81</td>
2024-03-21 16:11:54 +00:00
<td>
Qualification for the
<a
href="https://en.wikipedia.org/wiki/2016%E2%80%9317_UEFA_Champions_League#Group_stage"
title="201617 UEFA Champions League"
>Champions League group stage</a
>
</td>
</tr>
<tr>
2016-10-30 12:20:51 +00:00
<th>2</th>
2024-03-21 16:11:54 +00:00
<td>
<a
href="https://en.wikipedia.org/wiki/Arsenal_F.C."
title="Arsenal F.C."
>Arsenal</a
>
</td>
2016-10-30 12:20:51 +00:00
<td>38</td>
<td>20</td>
<td>11</td>
<td>7</td>
<td>65</td>
<td>36</td>
<td>+29</td>
<td>71</td>
2024-03-21 16:11:54 +00:00
<td>
Qualification for the
<a
href="https://en.wikipedia.org/wiki/2016%E2%80%9317_UEFA_Champions_League#Group_stage"
title="201617 UEFA Champions League"
>Champions League group stage</a
>
</td>
</tr>
<tr>
2016-10-30 12:20:51 +00:00
<th>3</th>
2024-03-21 16:11:54 +00:00
<td>
<a
href="https://en.wikipedia.org/wiki/Tottenham_Hotspur_F.C."
title="Tottenham Hotspur F.C."
>Tottenham Hotspur</a
>
</td>
2016-10-30 12:20:51 +00:00
<td>38</td>
<td>19</td>
<td>13</td>
<td>6</td>
<td>69</td>
<td>35</td>
<td>+34</td>
<td>70</td>
2024-03-21 16:11:54 +00:00
<td>
Qualification for the
<a
href="https://en.wikipedia.org/wiki/2016%E2%80%9317_UEFA_Champions_League#Group_stage"
title="201617 UEFA Champions League"
>Champions League group stage</a
>
</td>
2016-10-30 12:20:51 +00:00
</tr>
2017-04-15 16:08:30 +00:00
<tr class="is-selected">
2016-10-30 12:20:51 +00:00
<th>4</th>
2024-03-21 16:11:54 +00:00
<td>
<a
href="https://en.wikipedia.org/wiki/Manchester_City_F.C."
title="Manchester City F.C."
>Manchester City</a
>
</td>
2016-10-30 12:20:51 +00:00
<td>38</td>
<td>19</td>
<td>9</td>
<td>10</td>
<td>71</td>
<td>41</td>
<td>+30</td>
<td>66</td>
2024-03-21 16:11:54 +00:00
<td>
Qualification for the
<a
href="https://en.wikipedia.org/wiki/2016%E2%80%9317_UEFA_Champions_League#Play-off_round"
title="201617 UEFA Champions League"
>Champions League play-off round</a
>
</td>
2016-10-30 12:20:51 +00:00
</tr>
<tr>
<th>5</th>
2024-03-21 16:11:54 +00:00
<td>
<a
href="https://en.wikipedia.org/wiki/Manchester_United_F.C."
title="Manchester United F.C."
>Manchester United</a
>
</td>
2016-10-30 12:20:51 +00:00
<td>38</td>
<td>19</td>
<td>9</td>
<td>10</td>
<td>49</td>
<td>35</td>
<td>+14</td>
<td>66</td>
2024-03-21 16:11:54 +00:00
<td>
Qualification for the
<a
href="https://en.wikipedia.org/wiki/2016%E2%80%9317_UEFA_Europa_League#Group_stage"
title="201617 UEFA Europa League"
>Europa League group stage</a
>
</td>
2016-10-30 12:20:51 +00:00
</tr>
<tr>
<th>6</th>
2024-03-21 16:11:54 +00:00
<td>
<a
href="https://en.wikipedia.org/wiki/Southampton_F.C."
title="Southampton F.C."
>Southampton</a
>
</td>
2016-10-30 12:20:51 +00:00
<td>38</td>
<td>18</td>
<td>9</td>
<td>11</td>
<td>59</td>
<td>41</td>
<td>+18</td>
<td>63</td>
2024-03-21 16:11:54 +00:00
<td>
Qualification for the
<a
href="https://en.wikipedia.org/wiki/2016%E2%80%9317_UEFA_Europa_League#Group_stage"
title="201617 UEFA Europa League"
>Europa League group stage</a
>
</td>
2016-10-30 12:20:51 +00:00
</tr>
<tr>
<th>7</th>
2024-03-21 16:11:54 +00:00
<td>
<a
href="https://en.wikipedia.org/wiki/West_Ham_United_F.C."
title="West Ham United F.C."
>West Ham United</a
>
</td>
2016-10-30 12:20:51 +00:00
<td>38</td>
<td>16</td>
<td>14</td>
<td>8</td>
<td>65</td>
<td>51</td>
<td>+14</td>
<td>62</td>
2024-03-21 16:11:54 +00:00
<td>
Qualification for the
<a
href="https://en.wikipedia.org/wiki/2016%E2%80%9317_UEFA_Europa_League#Third_qualifying_round"
title="201617 UEFA Europa League"
>Europa League third qualifying round</a
>
</td>
2016-10-30 12:20:51 +00:00
</tr>
<tr>
<th>8</th>
2024-03-21 16:11:54 +00:00
<td>
<a
href="https://en.wikipedia.org/wiki/Liverpool_F.C."
title="Liverpool F.C."
>Liverpool</a
>
</td>
2016-10-30 12:20:51 +00:00
<td>38</td>
<td>16</td>
<td>12</td>
<td>10</td>
<td>63</td>
<td>50</td>
<td>+13</td>
<td>60</td>
<td></td>
</tr>
<tr>
<th>9</th>
2024-03-21 16:11:54 +00:00
<td>
<a
href="https://en.wikipedia.org/wiki/Stoke_City_F.C."
title="Stoke City F.C."
>Stoke City</a
>
</td>
2016-10-30 12:20:51 +00:00
<td>38</td>
<td>14</td>
<td>9</td>
<td>15</td>
<td>41</td>
<td>55</td>
<td>14</td>
<td>51</td>
<td></td>
</tr>
<tr>
<th>10</th>
2024-03-21 16:11:54 +00:00
<td>
<a
href="https://en.wikipedia.org/wiki/Chelsea_F.C."
title="Chelsea F.C."
>Chelsea</a
>
</td>
2016-10-30 12:20:51 +00:00
<td>38</td>
<td>12</td>
<td>14</td>
<td>12</td>
<td>59</td>
<td>53</td>
<td>+6</td>
<td>50</td>
<td></td>
</tr>
<tr>
<th>11</th>
2024-03-21 16:11:54 +00:00
<td>
<a
href="https://en.wikipedia.org/wiki/Everton_F.C."
title="Everton F.C."
>Everton</a
>
</td>
2016-10-30 12:20:51 +00:00
<td>38</td>
<td>11</td>
<td>14</td>
<td>13</td>
<td>59</td>
<td>55</td>
<td>+4</td>
<td>47</td>
<td></td>
</tr>
<tr>
<th>12</th>
2024-03-21 16:11:54 +00:00
<td>
<a
href="https://en.wikipedia.org/wiki/Swansea_City_A.F.C."
title="Swansea City A.F.C."
>Swansea City</a
>
</td>
2016-10-30 12:20:51 +00:00
<td>38</td>
<td>12</td>
<td>11</td>
<td>15</td>
<td>42</td>
<td>52</td>
<td>10</td>
<td>47</td>
<td></td>
</tr>
<tr>
<th>13</th>
2024-03-21 16:11:54 +00:00
<td>
<a
href="https://en.wikipedia.org/wiki/Watford_F.C."
title="Watford F.C."
>Watford</a
>
</td>
2016-10-30 12:20:51 +00:00
<td>38</td>
<td>12</td>
<td>9</td>
<td>17</td>
<td>40</td>
<td>50</td>
<td>10</td>
<td>45</td>
<td></td>
</tr>
<tr>
<th>14</th>
2024-03-21 16:11:54 +00:00
<td>
<a
href="https://en.wikipedia.org/wiki/West_Bromwich_Albion_F.C."
title="West Bromwich Albion F.C."
>West Bromwich Albion</a
>
</td>
2016-10-30 12:20:51 +00:00
<td>38</td>
<td>10</td>
<td>13</td>
<td>15</td>
<td>34</td>
<td>48</td>
<td>14</td>
<td>43</td>
<td></td>
</tr>
<tr>
<th>15</th>
2024-03-21 16:11:54 +00:00
<td>
<a
href="https://en.wikipedia.org/wiki/Crystal_Palace_F.C."
title="Crystal Palace F.C."
>Crystal Palace</a
>
</td>
2016-10-30 12:20:51 +00:00
<td>38</td>
<td>11</td>
<td>9</td>
<td>18</td>
<td>39</td>
<td>51</td>
<td>12</td>
<td>42</td>
<td></td>
</tr>
<tr>
<th>16</th>
2024-03-21 16:11:54 +00:00
<td>
<a
href="https://en.wikipedia.org/wiki/A.F.C._Bournemouth"
title="A.F.C. Bournemouth"
>AFC Bournemouth</a
>
</td>
2016-10-30 12:20:51 +00:00
<td>38</td>
<td>11</td>
<td>9</td>
<td>18</td>
<td>45</td>
<td>67</td>
<td>22</td>
<td>42</td>
<td></td>
</tr>
<tr>
<th>17</th>
2024-03-21 16:11:54 +00:00
<td>
<a
href="https://en.wikipedia.org/wiki/Sunderland_A.F.C."
title="Sunderland A.F.C."
>Sunderland</a
>
</td>
2016-10-30 12:20:51 +00:00
<td>38</td>
<td>9</td>
<td>12</td>
<td>17</td>
<td>48</td>
<td>62</td>
<td>14</td>
<td>39</td>
<td></td>
</tr>
<tr>
<th>18</th>
2024-03-21 16:11:54 +00:00
<td>
<a
href="https://en.wikipedia.org/wiki/Newcastle_United_F.C."
title="Newcastle United F.C."
>Newcastle United</a
>
<strong>(R)</strong>
</td>
2016-10-30 12:20:51 +00:00
<td>38</td>
<td>9</td>
<td>10</td>
<td>19</td>
<td>44</td>
<td>65</td>
<td>21</td>
<td>37</td>
2024-03-21 16:11:54 +00:00
<td>
Relegation to the
<a
href="https://en.wikipedia.org/wiki/2016%E2%80%9317_Football_League_Championship"
title="201617 Football League Championship"
>Football League Championship</a
>
</td>
</tr>
<tr>
2016-10-30 12:20:51 +00:00
<th>19</th>
2024-03-21 16:11:54 +00:00
<td>
<a
href="https://en.wikipedia.org/wiki/Norwich_City_F.C."
title="Norwich City F.C."
>Norwich City</a
>
<strong>(R)</strong>
</td>
2016-10-30 12:20:51 +00:00
<td>38</td>
<td>9</td>
<td>7</td>
<td>22</td>
<td>39</td>
<td>67</td>
<td>28</td>
<td>34</td>
2024-03-21 16:11:54 +00:00
<td>
Relegation to the
<a
href="https://en.wikipedia.org/wiki/2016%E2%80%9317_Football_League_Championship"
title="201617 Football League Championship"
>Football League Championship</a
>
</td>
</tr>
2016-10-30 12:20:51 +00:00
<tr>
<th>20</th>
2024-03-21 16:11:54 +00:00
<td>
<a
href="https://en.wikipedia.org/wiki/Aston_Villa_F.C."
title="Aston Villa F.C."
>Aston Villa</a
>
<strong>(R)</strong>
</td>
2016-10-30 12:20:51 +00:00
<td>38</td>
<td>3</td>
<td>8</td>
<td>27</td>
<td>27</td>
<td>76</td>
<td>49</td>
<td>17</td>
2024-03-21 16:11:54 +00:00
<td>
Relegation to the
<a
href="https://en.wikipedia.org/wiki/2016%E2%80%9317_Football_League_Championship"
title="201617 Football League Championship"
>Football League Championship</a
>
</td>
</tr>
</tbody>
</table>
2016-10-30 12:20:51 +00:00
{% endcapture %}
2024-03-21 16:11:54 +00:00
{% capture table_colors %}
<table class="table is-bordered">
<tbody>
{% for color in site.data.colors.justColors %}
<tr>
<th class="is-{{ color }}">{{ color | capitalize }} th cell</th>
<td>Two</td>
<td class="is-{{ color }}">{{ color | capitalize }} td cell</td>
<td>Four</td>
<td>Five</td>
</tr>
<tr class="is-{{ color }}">
<th>{{ color | capitalize }} row</th>
<td>Two</td>
<td>Three</td>
<td>Four</td>
<td>Five</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endcapture %}
2018-04-09 13:15:31 +00:00
<div class="content">
2019-10-13 18:20:44 +00:00
<p>
2024-03-21 16:11:54 +00:00
You can create a <strong>Bulma table</strong> simply by attaching a single <code>table</code> CSS class on a
<code>&lt;table&gt;</code> HTML element with the following structure:
2019-10-13 18:20:44 +00:00
</p>
2018-04-09 13:15:31 +00:00
<ul>
<li>
2024-03-21 16:11:54 +00:00
<code>&lt;table class="table"&gt;</code> as the main
<strong>container</strong>
2017-07-28 21:57:51 +00:00
<ul>
2024-03-21 16:11:54 +00:00
<li><code>thead</code> the optional <strong>top</strong> part of the table</li>
<li><code>tfoot</code> the optional <strong>bottom</strong> part of the table</li>
2018-04-09 13:15:31 +00:00
<li>
<code>tbody</code> the main <strong>content</strong> of the table
2017-07-28 21:57:51 +00:00
<ul>
<li>
2018-04-09 13:15:31 +00:00
<code>tr</code> each table <strong>row</strong>
2017-07-28 21:57:51 +00:00
<ul>
2024-03-21 16:11:54 +00:00
<li><code>th</code> a table cell <strong>heading</strong></li>
<li><code>td</code> a table <strong>cell</strong></li>
2017-07-28 21:57:51 +00:00
</ul>
</li>
</ul>
</li>
</ul>
2018-04-09 13:15:31 +00:00
</li>
</ul>
<p>
2024-03-21 16:11:54 +00:00
You can set a table row as <strong>selected</strong> by appending the <code>is-selected</code> modifier on a
<code>&lt;tr&gt;</code>
2018-04-09 13:15:31 +00:00
</p>
</div>
2017-07-28 21:57:51 +00:00
2024-03-21 16:11:54 +00:00
{%
include docs/elements/snippet.html content=table_example horizontal=true
more=true
%}
2024-03-21 16:11:54 +00:00
{% include docs/elements/anchor.html name="Colors" %}
<div class="content">
<p>
You can change the color of a single <code>&lt;td&gt;</code> or <code>&lt;th&gt;</code> cell, or a whole
<code>&lt;tr&gt;</code> row, by adding one of the color modifiers:
</p>
<ul>
<li><code>is-primary</code></li>
<li><code>is-link</code></li>
<li><code>is-info</code></li>
<li><code>is-success</code></li>
<li><code>is-warning</code></li>
<li><code>is-danger</code></li>
<li><code>is-black</code></li>
<li><code>is-dark</code></li>
<li><code>is-light</code></li>
<li><code>is-white</code></li>
</ul>
</div>
{%
include docs/elements/snippet.html content=table_colors horizontal=true
more=true
%}
{% include docs/elements/anchor.html name="Modifiers" %}
2019-07-25 08:55:58 +00:00
{% capture scrollable_table %}
2019-07-25 00:06:57 +00:00
<div class="table-container">
<table class="table">
2019-07-25 08:55:58 +00:00
<!-- Your table content -->
</table>
</div>
{% endcapture %}
{% capture simple_scrollable_table_example %}
<div class="table-container">
2024-03-21 16:11:54 +00:00
<table class="table is-bordered is-striped">
2019-07-25 08:55:58 +00:00
<tbody>
{% for i in (1..5) %}
2024-03-21 16:11:54 +00:00
<tr>
{% for j in (1..100) %}
<td>{{ j | times: i }}</td>
{% endfor %}
</tr>
2019-07-25 08:55:58 +00:00
{% endfor %}
</tbody>
2019-07-25 00:06:57 +00:00
</table>
</div>
{% endcapture %}
2018-04-09 13:15:31 +00:00
<div class="columns">
<div class="column">
<p>Add <strong>borders</strong> to all the cells.</p>
</div>
<div class="column">
<code>table is-bordered</code>
</div>
<div class="column is-half">
<table class="table is-bordered">
<thead>
<tr>
<th>One</th>
<th>Two</th>
</tr>
</thead>
<tbody>
<tr>
<td>Three</td>
<td>Four</td>
</tr>
</tbody>
</table>
</div>
</div>
2018-04-09 13:15:31 +00:00
<div class="columns">
<div class="column">
<p>Add <strong>stripes</strong> to the table.</p>
</div>
<div class="column">
<code>table is-striped</code>
</div>
<div class="column is-half">
<table class="table is-striped">
<thead>
<tr>
<th>One</th>
<th>Two</th>
</tr>
</thead>
<tbody>
<tr>
<td>Three</td>
<td>Four</td>
</tr>
<tr>
<td>Five</td>
<td>Six</td>
</tr>
<tr>
<td>Seven</td>
<td>Eight</td>
</tr>
<tr>
<td>Nine</td>
<td>Ten</td>
</tr>
<tr>
<td>Eleven</td>
<td>Twelve</td>
</tr>
</tbody>
</table>
</div>
</div>
2017-10-07 15:57:19 +00:00
2018-04-09 13:15:31 +00:00
<div class="columns">
<div class="column">
<p>Make the cells <strong>narrower</strong>.</p>
</div>
<div class="column">
<code>table is-narrow</code>
</div>
<div class="column is-half">
<table class="table is-narrow">
<thead>
<tr>
<th>One</th>
<th>Two</th>
</tr>
</thead>
<tbody>
<tr>
<td>Three</td>
<td>Four</td>
</tr>
<tr>
<td>Five</td>
<td>Six</td>
</tr>
<tr>
<td>Seven</td>
<td>Eight</td>
</tr>
<tr>
<td>Nine</td>
<td>Ten</td>
</tr>
<tr>
<td>Eleven</td>
<td>Twelve</td>
</tr>
</tbody>
</table>
</div>
</div>
2017-07-28 21:57:51 +00:00
2018-04-09 13:15:31 +00:00
<div class="columns">
<div class="column">
<p>You can add a <strong>hover effect</strong> on each row</p>
</div>
<div class="column">
<code>table is-hoverable</code>
</div>
<div class="column is-half">
<table class="table is-hoverable">
<thead>
<tr>
<th>One</th>
<th>Two</th>
</tr>
</thead>
<tbody>
<tr>
<td>Three</td>
<td>Four</td>
</tr>
<tr>
<td>Five</td>
<td>Six</td>
</tr>
<tr>
<td>Seven</td>
<td>Eight</td>
</tr>
<tr>
<td>Nine</td>
<td>Ten</td>
</tr>
<tr>
<td>Eleven</td>
<td>Twelve</td>
</tr>
</tbody>
</table>
</div>
</div>
2017-07-28 21:57:51 +00:00
2018-04-09 13:15:31 +00:00
<div class="columns">
<div class="column">
<p>You can have a <strong>fullwidth</strong> table.</p>
</div>
<div class="column">
<code>table is-fullwidth</code>
</div>
<div class="column is-half">
<table class="table is-fullwidth">
<thead>
<tr>
<th>One</th>
<th>Two</th>
</tr>
</thead>
<tbody>
<tr>
<td>Three</td>
<td>Four</td>
</tr>
<tr>
<td>Five</td>
<td>Six</td>
</tr>
<tr>
<td>Seven</td>
<td>Eight</td>
</tr>
<tr>
<td>Nine</td>
<td>Ten</td>
</tr>
<tr>
<td>Eleven</td>
<td>Twelve</td>
</tr>
</tbody>
</table>
</div>
</div>
2017-07-28 21:57:51 +00:00
2018-04-09 13:15:31 +00:00
<div class="columns">
<div class="column">
<p>You can <strong>combine</strong> all five modifiers.</p>
</div>
<div class="column">
<code>table is-bordered is-striped is-narrow is-hoverable is-fullwidth</code>
</div>
2018-04-09 13:15:31 +00:00
<div class="column is-half">
2024-03-21 16:11:54 +00:00
<table
class="table is-bordered is-striped is-narrow is-hoverable is-fullwidth"
>
2018-04-09 13:15:31 +00:00
<thead>
<tr>
<th>One</th>
<th>Two</th>
</tr>
</thead>
<tbody>
<tr>
<td>Three</td>
<td>Four</td>
</tr>
<tr>
<td>Five</td>
<td>Six</td>
</tr>
<tr>
<td>Seven</td>
<td>Eight</td>
</tr>
<tr>
<td>Nine</td>
<td>Ten</td>
</tr>
<tr>
<td>Eleven</td>
<td>Twelve</td>
</tr>
</tbody>
</table>
</div>
</div>
2024-03-21 16:11:54 +00:00
{% include docs/elements/anchor.html name="Table container" %}
2019-07-25 00:06:57 +00:00
2019-07-25 08:55:58 +00:00
<p class="content">
2024-03-21 16:11:54 +00:00
You can create a <strong>scrollable table</strong> by wrapping a <code>table</code> in a
<code>table-container</code> element:
2019-07-25 08:55:58 +00:00
</p>
2024-03-21 16:11:54 +00:00
{% highlight html -%}
{{- scrollable_table -}}
{%- endhighlight %}
2019-07-25 08:55:58 +00:00
{{ simple_scrollable_table_example }}
2024-03-21 16:11:54 +00:00
{%
include docs/components/variables.html
type='element'
%}