CSS-tables.txt 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. Tables
  2. ======
  3. Basic example
  4. -------------
  5. For basic styling—light padding and only horizontal dividers—add the base class
  6. .table to any `<table>`. It may seem super redundant, but given the widespread
  7. use of tables for other plugins like calendars and date pickers, we've opted to
  8. isolate our custom table styles.
  9. .. container:: bs-example
  10. = ========== ========= ========
  11. # First Name Last Name Username
  12. = ========== ========= ========
  13. 1 Mark Otto @mdo
  14. 2 Jacob Thornton @fat
  15. 3 Larry the Bird @twitter
  16. = ========== ========= ========
  17. .. code::
  18. :class: highlight
  19. = ========== ========= ========
  20. # First Name Last Name Username
  21. = ========== ========= ========
  22. 1 Mark Otto @mdo
  23. 2 Jacob Thornton @fat
  24. 3 Larry the Bird @twitter
  25. = ========== ========= ========
  26. Striped rows
  27. ------------
  28. Use `table-striped` to add zebra-striping to any table row within the `<tbody>`.
  29. .. ----------------------------------------------------------------------------
  30. .. callout:: danger
  31. :h4:`Cross-browser compatibility`
  32. Striped tables are styled via the `:nth-child` CSS selector, which is not
  33. available in Internet Explorer 8.
  34. .. ----------------------------------------------------------------------------
  35. .. container:: bs-example
  36. .. class:: table-striped
  37. = ========== ========= ========
  38. # First Name Last Name Username
  39. = ========== ========= ========
  40. 1 Mark Otto @mdo
  41. 2 Jacob Thornton @fat
  42. 3 Larry the Bird @twitter
  43. = ========== ========= ========
  44. .. code::
  45. :class: highlight
  46. .. class:: table-striped
  47. = ========== ========= ========
  48. # First Name Last Name Username
  49. = ========== ========= ========
  50. 1 Mark Otto @mdo
  51. 2 Jacob Thornton @fat
  52. 3 Larry the Bird @twitter
  53. = ========== ========= ========
  54. Bordered table
  55. --------------
  56. Add `table-bordered` for borders on all sides of the table and cells.
  57. .. container:: bs-example
  58. .. class:: table-bordered table-striped
  59. = ========== ========= ========
  60. # First Name Last Name Username
  61. = ========== ========= ========
  62. 1 Mark Otto @mdo
  63. 2 Jacob Thornton @fat
  64. 3 Larry the Bird @twitter
  65. = ========== ========= ========
  66. .. code::
  67. :class: highlight
  68. .. class:: table-bordered table-striped
  69. = ========== ========= ========
  70. # First Name Last Name Username
  71. = ========== ========= ========
  72. 1 Mark Otto @mdo
  73. 2 Jacob Thornton @fat
  74. 3 Larry the Bird @twitter
  75. = ========== ========= ========
  76. Hover rows
  77. ----------
  78. Add `table-hover` to enable a hover state on table rows within a `<tbody>`.
  79. .. container:: bs-example
  80. .. class:: table-hover
  81. = ========== ========= ========
  82. # First Name Last Name Username
  83. = ========== ========= ========
  84. 1 Mark Otto @mdo
  85. 2 Jacob Thornton @fat
  86. 3 Larry the Bird @twitter
  87. = ========== ========= ========
  88. .. code::
  89. :class: highlight
  90. .. class:: table-hover
  91. = ========== ========= ========
  92. # First Name Last Name Username
  93. = ========== ========= ========
  94. 1 Mark Otto @mdo
  95. 2 Jacob Thornton @fat
  96. 3 Larry the Bird @twitter
  97. = ========== ========= ========
  98. Condensed table
  99. ---------------
  100. Add `table-condensed` to make tables more compact by cutting cell padding in half.
  101. .. container:: bs-example
  102. .. class:: table-condensed
  103. = ========== ========= ========
  104. # First Name Last Name Username
  105. = ========== ========= ========
  106. 1 Mark Otto @mdo
  107. 2 Jacob Thornton @fat
  108. 3 Larry the Bird @twitter
  109. = ========== ========= ========
  110. .. code::
  111. :class: highlight
  112. .. class:: table-condensed
  113. = ========== ========= ========
  114. # First Name Last Name Username
  115. = ========== ========= ========
  116. 1 Mark Otto @mdo
  117. 2 Jacob Thornton @fat
  118. 3 Larry the Bird @twitter
  119. = ========== ========= ========
  120. Contextual classes
  121. ------------------
  122. Use contextual classes to color table rows or individual cells.
  123. .. container:: bs-example
  124. .. list-table::
  125. :widths: 10 30 30 30
  126. * - #
  127. - Column heading
  128. - Column heading
  129. - Column heading
  130. * .. class:: active
  131. - 1
  132. - Column content
  133. - Column content
  134. - Column content
  135. * - 2
  136. - Column heading
  137. - Column heading
  138. - Column heading
  139. * .. class:: success
  140. - 3
  141. - Column content
  142. - Column content
  143. - Column content
  144. * - 4
  145. - Column heading
  146. - Column heading
  147. - Column heading
  148. * .. class:: warning
  149. - 5
  150. - Column content
  151. - Column content
  152. - Column content
  153. * - 6
  154. - Column heading
  155. - Column heading
  156. - Column heading
  157. * .. class:: danger
  158. - 7
  159. - Column content
  160. - Column content
  161. - Column content
  162. * - 8
  163. - Column heading
  164. - Column heading
  165. - Column heading
  166. * .. class:: info
  167. - 9
  168. - Column content
  169. - Column content
  170. - Column content
  171. .. code::
  172. :class: highlight
  173. .. list-table::
  174. :widths: 10 30 30 30
  175. * - #
  176. - Column heading
  177. - Column heading
  178. - Column heading
  179. * .. class:: active
  180. - 1
  181. - Column content
  182. - Column content
  183. - Column content
  184. Responsive tables
  185. -----------------
  186. Create responsive tables by wrapping any `.table` in `.table-responsive` to
  187. make them scroll horizontally up to small devices (under 768px). When viewing
  188. on anything larger than 768px wide, you will not see any difference in these
  189. tables.
  190. .. container:: bs-example
  191. .. container:: table-responsive
  192. .. class:: table-bordered table-striped
  193. = ============= ============= ============= ============= =============
  194. # Table heading Table heading Table heading Table heading Table heading
  195. = ============= ============= ============= ============= =============
  196. 1 Table cell Table cell Table cell Table cell Table cell
  197. 2 Table cell Table cell Table cell Table cell Table cell
  198. 3 Table cell Table cell Table cell Table cell Table cell
  199. = ============= ============= ============= ============= =============
  200. .. code::
  201. :class: highlight
  202. .. container:: table-responsive
  203. .. class:: table-bordered table-striped
  204. = ============= ============= ============= ============= =============
  205. # Table heading Table heading Table heading Table heading Table heading
  206. = ============= ============= ============= ============= =============
  207. 1 Table cell Table cell Table cell Table cell Table cell
  208. 2 Table cell Table cell Table cell Table cell Table cell
  209. 3 Table cell Table cell Table cell Table cell Table cell
  210. = ============= ============= ============= ============= =============