table.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. ---
  2. title: Table
  3. layout: documentation
  4. doc-tab: elements
  5. doc-subtab: table
  6. variables:
  7. - name: $table-color
  8. value: $grey-darker
  9. - name: $table-background-color
  10. value: $white
  11. - name: $table-cell-border
  12. value: 1px solid $grey-lighter
  13. - name: $table-cell-border-width
  14. value: 0 0 1px
  15. - name: $table-cell-padding
  16. value: 0.5em 0.75em
  17. - name: $table-cell-heading-color
  18. value: $text-strong
  19. - name: $table-head-color
  20. value: $grey
  21. - name: $table-head-cell-border-width
  22. value: 0 0 2px
  23. - name: $table-head-cell-color
  24. value: $text-strong
  25. - name: $table-foot-cell-border-width
  26. value: 2px 0 0
  27. - name: $table-foot-cell-color
  28. value: $text-strong
  29. - name: $table-row-hover-background-color
  30. value: $white-bis
  31. - name: $table-row-active-background-color
  32. value: $primary
  33. - name: $table-row-active-color
  34. value: $primary-invert
  35. - name: $table-striped-row-even-background-color
  36. value: $white-bis
  37. - name: $table-striped-row-even-hover-background-color
  38. value: $white-ter
  39. ---
  40. {% capture table_example %}
  41. <table class="table">
  42. <thead>
  43. <tr>
  44. <th><abbr title="Position">Pos</abbr></th>
  45. <th>Team</th>
  46. <th><abbr title="Played">Pld</abbr></th>
  47. <th><abbr title="Won">W</abbr></th>
  48. <th><abbr title="Drawn">D</abbr></th>
  49. <th><abbr title="Lost">L</abbr></th>
  50. <th><abbr title="Goals for">GF</abbr></th>
  51. <th><abbr title="Goals against">GA</abbr></th>
  52. <th><abbr title="Goal difference">GD</abbr></th>
  53. <th><abbr title="Points">Pts</abbr></th>
  54. <th>Qualification or relegation</th>
  55. </tr>
  56. </thead>
  57. <tfoot>
  58. <tr>
  59. <th><abbr title="Position">Pos</abbr></th>
  60. <th>Team</th>
  61. <th><abbr title="Played">Pld</abbr></th>
  62. <th><abbr title="Won">W</abbr></th>
  63. <th><abbr title="Drawn">D</abbr></th>
  64. <th><abbr title="Lost">L</abbr></th>
  65. <th><abbr title="Goals for">GF</abbr></th>
  66. <th><abbr title="Goals against">GA</abbr></th>
  67. <th><abbr title="Goal difference">GD</abbr></th>
  68. <th><abbr title="Points">Pts</abbr></th>
  69. <th>Qualification or relegation</th>
  70. </tr>
  71. </tfoot>
  72. <tbody>
  73. <tr>
  74. <th>1</th>
  75. <td><a href="https://en.wikipedia.org/wiki/Leicester_City_F.C." title="Leicester City F.C.">Leicester City</a> <strong>(C)</strong>
  76. </td>
  77. <td>38</td>
  78. <td>23</td>
  79. <td>12</td>
  80. <td>3</td>
  81. <td>68</td>
  82. <td>36</td>
  83. <td>+32</td>
  84. <td>81</td>
  85. <td>Qualification for the <a href="https://en.wikipedia.org/wiki/2016%E2%80%9317_UEFA_Champions_League#Group_stage" title="2016–17 UEFA Champions League">Champions League group stage</a></td>
  86. </tr>
  87. <tr>
  88. <th>2</th>
  89. <td><a href="https://en.wikipedia.org/wiki/Arsenal_F.C." title="Arsenal F.C.">Arsenal</a></td>
  90. <td>38</td>
  91. <td>20</td>
  92. <td>11</td>
  93. <td>7</td>
  94. <td>65</td>
  95. <td>36</td>
  96. <td>+29</td>
  97. <td>71</td>
  98. <td>Qualification for the <a href="https://en.wikipedia.org/wiki/2016%E2%80%9317_UEFA_Champions_League#Group_stage" title="2016–17 UEFA Champions League">Champions League group stage</a></td>
  99. </tr>
  100. <tr>
  101. <th>3</th>
  102. <td><a href="https://en.wikipedia.org/wiki/Tottenham_Hotspur_F.C." title="Tottenham Hotspur F.C.">Tottenham Hotspur</a></td>
  103. <td>38</td>
  104. <td>19</td>
  105. <td>13</td>
  106. <td>6</td>
  107. <td>69</td>
  108. <td>35</td>
  109. <td>+34</td>
  110. <td>70</td>
  111. <td>Qualification for the <a href="https://en.wikipedia.org/wiki/2016%E2%80%9317_UEFA_Champions_League#Group_stage" title="2016–17 UEFA Champions League">Champions League group stage</a></td>
  112. </tr>
  113. <tr class="is-selected">
  114. <th>4</th>
  115. <td><a href="https://en.wikipedia.org/wiki/Manchester_City_F.C." title="Manchester City F.C.">Manchester City</a></td>
  116. <td>38</td>
  117. <td>19</td>
  118. <td>9</td>
  119. <td>10</td>
  120. <td>71</td>
  121. <td>41</td>
  122. <td>+30</td>
  123. <td>66</td>
  124. <td>Qualification for the <a href="https://en.wikipedia.org/wiki/2016%E2%80%9317_UEFA_Champions_League#Play-off_round" title="2016–17 UEFA Champions League">Champions League play-off round</a></td>
  125. </tr>
  126. <tr>
  127. <th>5</th>
  128. <td><a href="https://en.wikipedia.org/wiki/Manchester_United_F.C." title="Manchester United F.C.">Manchester United</a></td>
  129. <td>38</td>
  130. <td>19</td>
  131. <td>9</td>
  132. <td>10</td>
  133. <td>49</td>
  134. <td>35</td>
  135. <td>+14</td>
  136. <td>66</td>
  137. <td>Qualification for the <a href="https://en.wikipedia.org/wiki/2016%E2%80%9317_UEFA_Europa_League#Group_stage" title="2016–17 UEFA Europa League">Europa League group stage</a></td>
  138. </tr>
  139. <tr>
  140. <th>6</th>
  141. <td><a href="https://en.wikipedia.org/wiki/Southampton_F.C." title="Southampton F.C.">Southampton</a></td>
  142. <td>38</td>
  143. <td>18</td>
  144. <td>9</td>
  145. <td>11</td>
  146. <td>59</td>
  147. <td>41</td>
  148. <td>+18</td>
  149. <td>63</td>
  150. <td>Qualification for the <a href="https://en.wikipedia.org/wiki/2016%E2%80%9317_UEFA_Europa_League#Group_stage" title="2016–17 UEFA Europa League">Europa League group stage</a></td>
  151. </tr>
  152. <tr>
  153. <th>7</th>
  154. <td><a href="https://en.wikipedia.org/wiki/West_Ham_United_F.C." title="West Ham United F.C.">West Ham United</a></td>
  155. <td>38</td>
  156. <td>16</td>
  157. <td>14</td>
  158. <td>8</td>
  159. <td>65</td>
  160. <td>51</td>
  161. <td>+14</td>
  162. <td>62</td>
  163. <td>Qualification for the <a href="https://en.wikipedia.org/wiki/2016%E2%80%9317_UEFA_Europa_League#Third_qualifying_round" title="2016–17 UEFA Europa League">Europa League third qualifying round</a></td>
  164. </tr>
  165. <tr>
  166. <th>8</th>
  167. <td><a href="https://en.wikipedia.org/wiki/Liverpool_F.C." title="Liverpool F.C.">Liverpool</a></td>
  168. <td>38</td>
  169. <td>16</td>
  170. <td>12</td>
  171. <td>10</td>
  172. <td>63</td>
  173. <td>50</td>
  174. <td>+13</td>
  175. <td>60</td>
  176. <td></td>
  177. </tr>
  178. <tr>
  179. <th>9</th>
  180. <td><a href="https://en.wikipedia.org/wiki/Stoke_City_F.C." title="Stoke City F.C.">Stoke City</a></td>
  181. <td>38</td>
  182. <td>14</td>
  183. <td>9</td>
  184. <td>15</td>
  185. <td>41</td>
  186. <td>55</td>
  187. <td>−14</td>
  188. <td>51</td>
  189. <td></td>
  190. </tr>
  191. <tr>
  192. <th>10</th>
  193. <td><a href="https://en.wikipedia.org/wiki/Chelsea_F.C." title="Chelsea F.C.">Chelsea</a></td>
  194. <td>38</td>
  195. <td>12</td>
  196. <td>14</td>
  197. <td>12</td>
  198. <td>59</td>
  199. <td>53</td>
  200. <td>+6</td>
  201. <td>50</td>
  202. <td></td>
  203. </tr>
  204. <tr>
  205. <th>11</th>
  206. <td><a href="https://en.wikipedia.org/wiki/Everton_F.C." title="Everton F.C.">Everton</a></td>
  207. <td>38</td>
  208. <td>11</td>
  209. <td>14</td>
  210. <td>13</td>
  211. <td>59</td>
  212. <td>55</td>
  213. <td>+4</td>
  214. <td>47</td>
  215. <td></td>
  216. </tr>
  217. <tr>
  218. <th>12</th>
  219. <td><a href="https://en.wikipedia.org/wiki/Swansea_City_A.F.C." title="Swansea City A.F.C.">Swansea City</a></td>
  220. <td>38</td>
  221. <td>12</td>
  222. <td>11</td>
  223. <td>15</td>
  224. <td>42</td>
  225. <td>52</td>
  226. <td>−10</td>
  227. <td>47</td>
  228. <td></td>
  229. </tr>
  230. <tr>
  231. <th>13</th>
  232. <td><a href="https://en.wikipedia.org/wiki/Watford_F.C." title="Watford F.C.">Watford</a></td>
  233. <td>38</td>
  234. <td>12</td>
  235. <td>9</td>
  236. <td>17</td>
  237. <td>40</td>
  238. <td>50</td>
  239. <td>−10</td>
  240. <td>45</td>
  241. <td></td>
  242. </tr>
  243. <tr>
  244. <th>14</th>
  245. <td><a href="https://en.wikipedia.org/wiki/West_Bromwich_Albion_F.C." title="West Bromwich Albion F.C.">West Bromwich Albion</a></td>
  246. <td>38</td>
  247. <td>10</td>
  248. <td>13</td>
  249. <td>15</td>
  250. <td>34</td>
  251. <td>48</td>
  252. <td>−14</td>
  253. <td>43</td>
  254. <td></td>
  255. </tr>
  256. <tr>
  257. <th>15</th>
  258. <td><a href="https://en.wikipedia.org/wiki/Crystal_Palace_F.C." title="Crystal Palace F.C.">Crystal Palace</a></td>
  259. <td>38</td>
  260. <td>11</td>
  261. <td>9</td>
  262. <td>18</td>
  263. <td>39</td>
  264. <td>51</td>
  265. <td>−12</td>
  266. <td>42</td>
  267. <td></td>
  268. </tr>
  269. <tr>
  270. <th>16</th>
  271. <td><a href="https://en.wikipedia.org/wiki/A.F.C._Bournemouth" title="A.F.C. Bournemouth">AFC Bournemouth</a></td>
  272. <td>38</td>
  273. <td>11</td>
  274. <td>9</td>
  275. <td>18</td>
  276. <td>45</td>
  277. <td>67</td>
  278. <td>−22</td>
  279. <td>42</td>
  280. <td></td>
  281. </tr>
  282. <tr>
  283. <th>17</th>
  284. <td><a href="https://en.wikipedia.org/wiki/Sunderland_A.F.C." title="Sunderland A.F.C.">Sunderland</a></td>
  285. <td>38</td>
  286. <td>9</td>
  287. <td>12</td>
  288. <td>17</td>
  289. <td>48</td>
  290. <td>62</td>
  291. <td>−14</td>
  292. <td>39</td>
  293. <td></td>
  294. </tr>
  295. <tr>
  296. <th>18</th>
  297. <td><a href="https://en.wikipedia.org/wiki/Newcastle_United_F.C." title="Newcastle United F.C.">Newcastle United</a> <strong>(R)</strong>
  298. </td>
  299. <td>38</td>
  300. <td>9</td>
  301. <td>10</td>
  302. <td>19</td>
  303. <td>44</td>
  304. <td>65</td>
  305. <td>−21</td>
  306. <td>37</td>
  307. <td>Relegation to the <a href="https://en.wikipedia.org/wiki/2016%E2%80%9317_Football_League_Championship" title="2016–17 Football League Championship">Football League Championship</a></td>
  308. </tr>
  309. <tr>
  310. <th>19</th>
  311. <td><a href="https://en.wikipedia.org/wiki/Norwich_City_F.C." title="Norwich City F.C.">Norwich City</a> <strong>(R)</strong>
  312. </td>
  313. <td>38</td>
  314. <td>9</td>
  315. <td>7</td>
  316. <td>22</td>
  317. <td>39</td>
  318. <td>67</td>
  319. <td>−28</td>
  320. <td>34</td>
  321. <td>Relegation to the <a href="https://en.wikipedia.org/wiki/2016%E2%80%9317_Football_League_Championship" title="2016–17 Football League Championship">Football League Championship</a></td> </tr>
  322. <tr>
  323. <th>20</th>
  324. <td><a href="https://en.wikipedia.org/wiki/Aston_Villa_F.C." title="Aston Villa F.C.">Aston Villa</a> <strong>(R)</strong>
  325. </td>
  326. <td>38</td>
  327. <td>3</td>
  328. <td>8</td>
  329. <td>27</td>
  330. <td>27</td>
  331. <td>76</td>
  332. <td>−49</td>
  333. <td>17</td>
  334. <td>Relegation to the <a href="https://en.wikipedia.org/wiki/2016%E2%80%9317_Football_League_Championship" title="2016–17 Football League Championship">Football League Championship</a></td>
  335. </tr>
  336. </tbody>
  337. </table>
  338. {% endcapture %}
  339. {% include subnav-elements.html %}
  340. <section class="section">
  341. <div class="container">
  342. <h1 class="title">Tables</h1>
  343. <h2 class="subtitle">The inevitable HTML <strong>table</strong>, with special case cells</h2>
  344. {%
  345. include meta.html
  346. colors=false
  347. sizes=false
  348. variables=true
  349. %}
  350. <hr>
  351. <div class="content">
  352. <p>You simply need to attach a single <code>.table</code> CSS class on a <code>&lt;table&gt;</code> with the following structure:</p>
  353. <ul>
  354. <li>
  355. <code>table</code> the main <strong>container</strong>
  356. <ul>
  357. <li>
  358. <code>thead</code> the optional <strong>top</strong> part of the table
  359. </li>
  360. <li>
  361. <code>tfoot</code> the optional <strong>bottom</strong> part of the table
  362. </li>
  363. <li>
  364. <code>tbody</code> the main <strong>content</strong> of the table
  365. <ul>
  366. <li>
  367. <code>tr</code> each table <strong>row</strong>
  368. <ul>
  369. <li>
  370. <code>th</code> a table cell <strong>heading</strong>
  371. </li>
  372. <li>
  373. <code>td</code> a table <strong>cell</strong>
  374. </li>
  375. </ul>
  376. </li>
  377. </ul>
  378. </li>
  379. </ul>
  380. </li>
  381. </ul>
  382. <p>
  383. <span class="tag is-success">New!</span>
  384. <span class="tag is-info">0.4.2</span>
  385. </p>
  386. <p>
  387. 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>
  388. </p>
  389. </div>
  390. <div class="bd-example">
  391. {{table_example}}
  392. </div>
  393. {% highlight html %}{{table_example}}{% endhighlight %}
  394. {% include anchor.html name="Modifiers" %}
  395. <div class="columns">
  396. <div class="column">
  397. <p>Add <strong>borders</strong> to all the cells.</p>
  398. </div>
  399. <div class="column">
  400. <code>table is-bordered</code>
  401. </div>
  402. <div class="column is-half">
  403. <table class="table is-bordered">
  404. <thead>
  405. <tr>
  406. <th>One</th>
  407. <th>Two</th>
  408. </tr>
  409. </thead>
  410. <tbody>
  411. <tr>
  412. <td>Three</td>
  413. <td>Four</td>
  414. </tr>
  415. </tbody>
  416. </table>
  417. </div>
  418. </div>
  419. <div class="columns">
  420. <div class="column">
  421. <p>Add <strong>stripes</strong> to the table.</p>
  422. </div>
  423. <div class="column">
  424. <code>table is-striped</code>
  425. </div>
  426. <div class="column is-half">
  427. <table class="table is-striped">
  428. <thead>
  429. <tr>
  430. <th>One</th>
  431. <th>Two</th>
  432. </tr>
  433. </thead>
  434. <tbody>
  435. <tr>
  436. <td>Three</td>
  437. <td>Four</td>
  438. </tr>
  439. <tr>
  440. <td>Five</td>
  441. <td>Six</td>
  442. </tr>
  443. <tr>
  444. <td>Seven</td>
  445. <td>Eight</td>
  446. </tr>
  447. <tr>
  448. <td>Nine</td>
  449. <td>Ten</td>
  450. </tr>
  451. <tr>
  452. <td>Eleven</td>
  453. <td>Twelve</td>
  454. </tr>
  455. </tbody>
  456. </table>
  457. </div>
  458. </div>
  459. <div class="columns">
  460. <div class="column">
  461. <p>Make the cells <strong>narrower</strong>.</p>
  462. </div>
  463. <div class="column">
  464. <code>table is-narrow</code>
  465. </div>
  466. <div class="column is-half">
  467. <table class="table is-narrow">
  468. <thead>
  469. <tr>
  470. <th>One</th>
  471. <th>Two</th>
  472. </tr>
  473. </thead>
  474. <tbody>
  475. <tr>
  476. <td>Three</td>
  477. <td>Four</td>
  478. </tr>
  479. <tr>
  480. <td>Five</td>
  481. <td>Six</td>
  482. </tr>
  483. <tr>
  484. <td>Seven</td>
  485. <td>Eight</td>
  486. </tr>
  487. <tr>
  488. <td>Nine</td>
  489. <td>Ten</td>
  490. </tr>
  491. <tr>
  492. <td>Eleven</td>
  493. <td>Twelve</td>
  494. </tr>
  495. </tbody>
  496. </table>
  497. </div>
  498. </div>
  499. <div class="columns">
  500. <div class="column">
  501. <p>You can have a <strong>fullwidth</strong> table.</p>
  502. </div>
  503. <div class="column">
  504. <code>table is-fullwidth</code>
  505. </div>
  506. <div class="column is-half">
  507. <table class="table is-fullwidth">
  508. <thead>
  509. <tr>
  510. <th>One</th>
  511. <th>Two</th>
  512. </tr>
  513. </thead>
  514. <tbody>
  515. <tr>
  516. <td>Three</td>
  517. <td>Four</td>
  518. </tr>
  519. <tr>
  520. <td>Five</td>
  521. <td>Six</td>
  522. </tr>
  523. <tr>
  524. <td>Seven</td>
  525. <td>Eight</td>
  526. </tr>
  527. <tr>
  528. <td>Nine</td>
  529. <td>Ten</td>
  530. </tr>
  531. <tr>
  532. <td>Eleven</td>
  533. <td>Twelve</td>
  534. </tr>
  535. </tbody>
  536. </table>
  537. </div>
  538. </div>
  539. <div class="columns">
  540. <div class="column">
  541. <p>You can <strong>combine</strong> all four modifiers.</p>
  542. </div>
  543. <div class="column">
  544. <code>table is-bordered is-striped is-narrow is-fullwidth</code>
  545. </div>
  546. <div class="column is-half">
  547. <table class="table is-bordered is-striped is-narrow is-fullwidth">
  548. <thead>
  549. <tr>
  550. <th>One</th>
  551. <th>Two</th>
  552. </tr>
  553. </thead>
  554. <tbody>
  555. <tr>
  556. <td>Three</td>
  557. <td>Four</td>
  558. </tr>
  559. <tr>
  560. <td>Five</td>
  561. <td>Six</td>
  562. </tr>
  563. <tr>
  564. <td>Seven</td>
  565. <td>Eight</td>
  566. </tr>
  567. <tr>
  568. <td>Nine</td>
  569. <td>Ten</td>
  570. </tr>
  571. <tr>
  572. <td>Eleven</td>
  573. <td>Twelve</td>
  574. </tr>
  575. </tbody>
  576. </table>
  577. </div>
  578. </div>
  579. {% include variables.html element=true %}
  580. </div>
  581. </section>