tables.less 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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. .table-vertically-centered-cells {
  60. > tbody > tr > td {
  61. vertical-align: middle;
  62. }
  63. }
  64. // Condensed table w/ half padding
  65. .table-condensed {
  66. > thead,
  67. > tbody,
  68. > tfoot {
  69. > tr {
  70. > th,
  71. > td {
  72. padding: @table-condensed-cell-padding;
  73. }
  74. }
  75. }
  76. }
  77. // Bordered versions
  78. //
  79. // Add borders all around the table and between all the columns.
  80. .table-bordered {
  81. border: 1px solid @table-border-color;
  82. > thead,
  83. > tbody,
  84. > tfoot {
  85. > tr {
  86. > th,
  87. > td {
  88. border: 1px solid @table-border-color;
  89. }
  90. }
  91. }
  92. > thead > tr {
  93. > th,
  94. > td {
  95. border-bottom-width: 2px;
  96. }
  97. }
  98. }
  99. // Zebra-striping
  100. //
  101. // Default zebra-stripe styles (alternating gray and transparent backgrounds)
  102. .table-striped {
  103. > tbody > tr:nth-child(odd) {
  104. > td,
  105. > th {
  106. background-color: @table-bg-accent;
  107. }
  108. }
  109. }
  110. // Hover effect
  111. //
  112. // Placed here since it has to come after the potential zebra striping
  113. .table-hover {
  114. > tbody > tr:hover {
  115. > td,
  116. > th {
  117. background-color: @table-bg-hover;
  118. }
  119. }
  120. }
  121. // Table cell sizing
  122. //
  123. // Reset default table behavior
  124. table col[class*='col-'] {
  125. position: static; // Prevent border hiding in Firefox and IE9/10 (see https://github.com/twbs/bootstrap/issues/11623)
  126. float: none;
  127. display: table-column;
  128. }
  129. table {
  130. td,
  131. th {
  132. &[class*='col-'] {
  133. position: static; // Prevent border hiding in Firefox and IE9/10 (see https://github.com/twbs/bootstrap/issues/11623)
  134. float: none;
  135. display: table-cell;
  136. }
  137. }
  138. }
  139. // Table backgrounds
  140. //
  141. // Exact selectors below required to override `.table-striped` and prevent
  142. // inheritance to nested tables.
  143. // Generate the contextual variants
  144. .table-row-variant(active; @table-bg-active);
  145. .table-row-variant(success; @state-success-bg);
  146. .table-row-variant(info; @state-info-bg);
  147. .table-row-variant(warning; @state-warning-bg);
  148. .table-row-variant(danger; @state-danger-bg);
  149. // Responsive tables
  150. //
  151. // Wrap your tables in `.table-responsive` and we'll make them mobile friendly
  152. // by enabling horizontal scrolling. Only applies <768px. Everything above that
  153. // will display normally.
  154. @media (max-width: @screen-xs-max) {
  155. .table-responsive {
  156. width: 100%;
  157. margin-bottom: (@line-height-computed * 0.75);
  158. overflow-y: hidden;
  159. overflow-x: scroll;
  160. -ms-overflow-style: -ms-autohiding-scrollbar;
  161. border: 1px solid @table-border-color;
  162. -webkit-overflow-scrolling: touch;
  163. // Tighten up spacing
  164. > .table {
  165. margin-bottom: 0;
  166. // Ensure the content doesn't wrap
  167. > thead,
  168. > tbody,
  169. > tfoot {
  170. > tr {
  171. > th,
  172. > td {
  173. white-space: nowrap;
  174. }
  175. }
  176. }
  177. }
  178. // Special overrides for the bordered tables
  179. > .table-bordered {
  180. border: 0;
  181. // Nuke the appropriate borders so that the parent can handle them
  182. > thead,
  183. > tbody,
  184. > tfoot {
  185. > tr {
  186. > th:first-child,
  187. > td:first-child {
  188. border-left: 0;
  189. }
  190. > th:last-child,
  191. > td:last-child {
  192. border-right: 0;
  193. }
  194. }
  195. }
  196. // Only nuke the last row's bottom-border in `tbody` and `tfoot` since
  197. // chances are there will be only one `tr` in a `thead` and that would
  198. // remove the border altogether.
  199. > tbody,
  200. > tfoot {
  201. > tr:last-child {
  202. > th,
  203. > td {
  204. border-bottom: 0;
  205. }
  206. }
  207. }
  208. }
  209. }
  210. }
  211. .table-outlined-container {
  212. border: @border-width-sm solid @table-border-color;
  213. padding: @padding-sm @padding-sm 0 @padding-sm;
  214. border-radius: @border-radius-base-new;
  215. table {
  216. margin-bottom: 0;
  217. }
  218. }