table.html 17 KB

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