_tables.less 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. //
  2. // Basic Bootstrap table
  3. //
  4. .table {
  5. width: 100%;
  6. margin-bottom: @spacer;
  7. color: @table-color;
  8. // LESS PORT: Less doesn’t strip “empty” property values so we have to check for a value first.
  9. & when not (@table-bg = ~"") { background-color: @table-bg; } // Reset for nesting within parents with `background-color`.
  10. th,
  11. td {
  12. padding: @table-cell-padding;
  13. vertical-align: top;
  14. border-top: @table-border-width solid @table-border-color;
  15. }
  16. thead th {
  17. vertical-align: bottom;
  18. border-bottom: (2 * @table-border-width) solid @table-border-color;
  19. }
  20. tbody + tbody {
  21. border-top: (2 * @table-border-width) solid @table-border-color;
  22. }
  23. }
  24. //
  25. // Condensed table w/ half padding
  26. //
  27. .table-sm {
  28. th,
  29. td {
  30. padding: @table-cell-padding-sm;
  31. }
  32. }
  33. // Border versions
  34. //
  35. // Add or remove borders all around the table and between all the columns.
  36. .table-bordered {
  37. border: @table-border-width solid @table-border-color;
  38. th,
  39. td {
  40. border: @table-border-width solid @table-border-color;
  41. }
  42. thead {
  43. th,
  44. td {
  45. border-bottom-width: (2 * @table-border-width);
  46. }
  47. }
  48. }
  49. .table-borderless {
  50. th,
  51. td,
  52. thead th,
  53. tbody + tbody {
  54. border: 0;
  55. }
  56. }
  57. // Zebra-striping
  58. //
  59. // Default zebra-stripe styles (alternating gray and transparent backgrounds)
  60. .table-striped {
  61. tbody tr:nth-of-type(@{table-striped-order}) {
  62. background-color: @table-accent-bg;
  63. }
  64. }
  65. // Hover effect
  66. //
  67. // Placed here since it has to come after the potential zebra striping
  68. .table-hover {
  69. tbody tr {
  70. #hover({
  71. color: @table-hover-color;
  72. background-color: @table-hover-bg;
  73. });
  74. }
  75. }
  76. // Table backgrounds
  77. //
  78. // Exact selectors below required to override `.table-striped` and prevent
  79. // inheritance to nested tables.
  80. each(@theme-colors, #(@value, @color) {
  81. #table-row-variant(@color, theme-color-level(@color, @table-bg-level), theme-color-level(@color, @table-border-level));
  82. });
  83. #table-row-variant(active, @table-active-bg);
  84. // Dark styles
  85. //
  86. // Same table markup, but inverted color scheme: dark background and light text.
  87. .table {
  88. .thead-dark {
  89. th {
  90. color: @table-dark-color;
  91. background-color: @table-dark-bg;
  92. border-color: @table-dark-border-color;
  93. }
  94. }
  95. .thead-light {
  96. th {
  97. color: @table-head-color;
  98. background-color: @table-head-bg;
  99. border-color: @table-border-color;
  100. }
  101. }
  102. }
  103. .table-dark {
  104. color: @table-dark-color;
  105. background-color: @table-dark-bg;
  106. th,
  107. td,
  108. thead th {
  109. border-color: @table-dark-border-color;
  110. }
  111. &.table-bordered {
  112. border: 0;
  113. }
  114. &.table-striped {
  115. tbody tr:nth-of-type(@{table-striped-order}) {
  116. background-color: @table-dark-accent-bg;
  117. }
  118. }
  119. &.table-hover {
  120. tbody tr {
  121. #hover({
  122. color: @table-dark-hover-color;
  123. background-color: @table-dark-hover-bg;
  124. });
  125. }
  126. }
  127. }
  128. // Responsive tables
  129. //
  130. // Generate series of `.table-responsive-*` classes for configuring the screen
  131. // size of where your table will overflow.
  132. //.table-responsive {
  133. // @each $breakpoint in map-keys($grid-breakpoints) {
  134. // $next: breakpoint-next($breakpoint, $grid-breakpoints);
  135. // $infix: breakpoint-infix($next, $grid-breakpoints);
  136. //
  137. // &#{$infix} {
  138. // @include media-breakpoint-down($breakpoint) {
  139. // display: block;
  140. // width: 100%;
  141. // overflow-x: auto;
  142. // -webkit-overflow-scrolling: touch;
  143. //
  144. // // Prevent double border on horizontal scroll due to use of `display: block;`
  145. // > .table-bordered {
  146. // border: 0;
  147. // }
  148. // }
  149. // }
  150. // }
  151. //}
  152. each(map-keys(@grid-breakpoints), #(@breakpoint) {
  153. .table-responsive {
  154. @next: breakpoint-next(@breakpoint, @grid-breakpoints);
  155. @infix: breakpoint-infix(@next, @grid-breakpoints);
  156. &@{infix} {
  157. #media-breakpoint-down(@breakpoint, {
  158. display: block;
  159. width: 100%;
  160. overflow-x: auto;
  161. -webkit-overflow-scrolling: touch;
  162. // Prevent double border on horizontal scroll due to use of `display: block;`
  163. > .table-bordered {
  164. border: 0;
  165. }
  166. });
  167. }
  168. }
  169. });