table.html 14 KB

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