tables.less 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. //
  2. // Tables
  3. // --------------------------------------------------
  4. table {
  5. max-width: 100%;
  6. background-color: @table-bg;
  7. }
  8. th {
  9. text-align: left;
  10. }
  11. // Baseline styles
  12. .table {
  13. width: 100%;
  14. margin-bottom: @line-height-computed;
  15. // Cells
  16. > thead,
  17. > tbody,
  18. > tfoot {
  19. > tr {
  20. > th,
  21. > td {
  22. padding: @table-cell-padding;
  23. line-height: @line-height-base;
  24. vertical-align: top;
  25. border-top: 1px solid @table-border-color;
  26. }
  27. }
  28. }
  29. // Bottom align for column headings
  30. > thead > tr > th {
  31. vertical-align: bottom;
  32. border-bottom: 2px solid @table-border-color;
  33. }
  34. // Remove top border from thead by default
  35. > caption + thead,
  36. > colgroup + thead,
  37. > thead:first-child {
  38. > tr:first-child {
  39. > th,
  40. > td {
  41. border-top: 0;
  42. }
  43. }
  44. }
  45. // Account for multiple tbody instances
  46. > tbody + tbody {
  47. border-top: 2px solid @table-border-color;
  48. }
  49. // Nesting
  50. .table {
  51. background-color: @body-bg;
  52. }
  53. }
  54. .table-fixed {
  55. .table;
  56. table-layout: fixed;
  57. word-wrap: break-word;
  58. }
  59. // Condensed table w/ half padding
  60. .table-condensed {
  61. > thead,
  62. > tbody,
  63. > tfoot {
  64. > tr {
  65. > th,
  66. > td {
  67. padding: @table-condensed-cell-padding;
  68. }
  69. }
  70. }
  71. }
  72. // Bordered version
  73. //
  74. // Add borders all around the table and between all the columns.
  75. .table-bordered {
  76. border: 1px solid @table-border-color;
  77. > thead,
  78. > tbody,
  79. > tfoot {
  80. > tr {
  81. > th,
  82. > td {
  83. border: 1px solid @table-border-color;
  84. }
  85. }
  86. }
  87. > thead > tr {
  88. > th,
  89. > td {
  90. border-bottom-width: 2px;
  91. }
  92. }
  93. }
  94. // Zebra-striping
  95. //
  96. // Default zebra-stripe styles (alternating gray and transparent backgrounds)
  97. .table-striped {
  98. > tbody > tr:nth-child(odd) {
  99. > td,
  100. > th {
  101. background-color: @table-bg-accent;
  102. }
  103. }
  104. }
  105. // Hover effect
  106. //
  107. // Placed here since it has to come after the potential zebra striping
  108. .table-hover {
  109. > tbody > tr:hover {
  110. > td,
  111. > th {
  112. background-color: @table-bg-hover;
  113. }
  114. }
  115. }
  116. // Table cell sizing
  117. //
  118. // Reset default table behavior
  119. table col[class*='col-'] {
  120. position: static; // Prevent border hiding in Firefox and IE9/10 (see https://github.com/twbs/bootstrap/issues/11623)
  121. float: none;
  122. display: table-column;
  123. }
  124. table {
  125. td,
  126. th {
  127. &[class*='col-'] {
  128. position: static; // Prevent border hiding in Firefox and IE9/10 (see https://github.com/twbs/bootstrap/issues/11623)
  129. float: none;
  130. display: table-cell;
  131. }
  132. }
  133. }
  134. // Table backgrounds
  135. //
  136. // Exact selectors below required to override `.table-striped` and prevent
  137. // inheritance to nested tables.
  138. // Generate the contextual variants
  139. .table-row-variant(active; @table-bg-active);
  140. .table-row-variant(success; @state-success-bg);
  141. .table-row-variant(info; @state-info-bg);
  142. .table-row-variant(warning; @state-warning-bg);
  143. .table-row-variant(danger; @state-danger-bg);
  144. // Responsive tables
  145. //
  146. // Wrap your tables in `.table-responsive` and we'll make them mobile friendly
  147. // by enabling horizontal scrolling. Only applies <768px. Everything above that
  148. // will display normally.
  149. @media (max-width: @screen-xs-max) {
  150. .table-responsive {
  151. width: 100%;
  152. margin-bottom: (@line-height-computed * 0.75);
  153. overflow-y: hidden;
  154. overflow-x: scroll;
  155. -ms-overflow-style: -ms-autohiding-scrollbar;
  156. border: 1px solid @table-border-color;
  157. -webkit-overflow-scrolling: touch;
  158. // Tighten up spacing
  159. > .table {
  160. margin-bottom: 0;
  161. // Ensure the content doesn't wrap
  162. > thead,
  163. > tbody,
  164. > tfoot {
  165. > tr {
  166. > th,
  167. > td {
  168. white-space: nowrap;
  169. }
  170. }
  171. }
  172. }
  173. // Special overrides for the bordered tables
  174. > .table-bordered {
  175. border: 0;
  176. // Nuke the appropriate borders so that the parent can handle them
  177. > thead,
  178. > tbody,
  179. > tfoot {
  180. > tr {
  181. > th:first-child,
  182. > td:first-child {
  183. border-left: 0;
  184. }
  185. > th:last-child,
  186. > td:last-child {
  187. border-right: 0;
  188. }
  189. }
  190. }
  191. // Only nuke the last row's bottom-border in `tbody` and `tfoot` since
  192. // chances are there will be only one `tr` in a `thead` and that would
  193. // remove the border altogether.
  194. > tbody,
  195. > tfoot {
  196. > tr:last-child {
  197. > th,
  198. > td {
  199. border-bottom: 0;
  200. }
  201. }
  202. }
  203. }
  204. }
  205. }