_tables.scss 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. //
  2. // Basic Bootstrap table
  3. //
  4. .table {
  5. width: 100%;
  6. margin-bottom: $spacer;
  7. background-color: $table-bg; // Reset for nesting within parents with `background-color`.
  8. th,
  9. td {
  10. padding: $table-cell-padding;
  11. vertical-align: top;
  12. border-top: $table-border-width solid $table-border-color;
  13. }
  14. thead th {
  15. vertical-align: bottom;
  16. border-bottom: (2 * $table-border-width) solid $table-border-color;
  17. }
  18. tbody + tbody {
  19. border-top: (2 * $table-border-width) solid $table-border-color;
  20. }
  21. .table {
  22. background-color: $body-bg;
  23. }
  24. }
  25. //
  26. // Condensed table w/ half padding
  27. //
  28. .table-sm {
  29. th,
  30. td {
  31. padding: $table-cell-padding-sm;
  32. }
  33. }
  34. // Border versions
  35. //
  36. // Add or remove borders all around the table and between all the columns.
  37. .table-bordered {
  38. border: $table-border-width solid $table-border-color;
  39. th,
  40. td {
  41. border: $table-border-width solid $table-border-color;
  42. }
  43. thead {
  44. th,
  45. td {
  46. border-bottom-width: (2 * $table-border-width);
  47. }
  48. }
  49. }
  50. .table-borderless {
  51. th,
  52. td,
  53. thead th,
  54. tbody + tbody {
  55. border: 0;
  56. }
  57. }
  58. // Zebra-striping
  59. //
  60. // Default zebra-stripe styles (alternating gray and transparent backgrounds)
  61. .table-striped {
  62. tbody tr:nth-of-type(#{$table-striped-order}) {
  63. background-color: $table-accent-bg;
  64. }
  65. }
  66. // Hover effect
  67. //
  68. // Placed here since it has to come after the potential zebra striping
  69. .table-hover {
  70. tbody tr {
  71. @include hover {
  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 $color, $value in $theme-colors {
  81. @include table-row-variant($color, theme-color-level($color, -9));
  82. }
  83. @include 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. // stylelint-disable-next-line no-duplicate-selectors
  88. .table {
  89. .thead-dark {
  90. th {
  91. color: $table-dark-color;
  92. background-color: $table-dark-bg;
  93. border-color: $table-dark-border-color;
  94. }
  95. }
  96. .thead-light {
  97. th {
  98. color: $table-head-color;
  99. background-color: $table-head-bg;
  100. border-color: $table-border-color;
  101. }
  102. }
  103. }
  104. .table-dark {
  105. color: $table-dark-color;
  106. background-color: $table-dark-bg;
  107. th,
  108. td,
  109. thead th {
  110. border-color: $table-dark-border-color;
  111. }
  112. &.table-bordered {
  113. border: 0;
  114. }
  115. &.table-striped {
  116. tbody tr:nth-of-type(odd) {
  117. background-color: $table-dark-accent-bg;
  118. }
  119. }
  120. &.table-hover {
  121. tbody tr {
  122. @include hover {
  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. &#{$infix} {
  137. @include media-breakpoint-down($breakpoint) {
  138. display: block;
  139. width: 100%;
  140. overflow-x: auto;
  141. -webkit-overflow-scrolling: touch;
  142. -ms-overflow-style: -ms-autohiding-scrollbar; // See https://github.com/twbs/bootstrap/pull/10057
  143. // Prevent double border on horizontal scroll due to use of `display: block;`
  144. > .table-bordered {
  145. border: 0;
  146. }
  147. }
  148. }
  149. }
  150. }