table.html 15 KB

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