_tables.scss 3.5 KB

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