table.html 14 KB

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