_tables.scss 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. // Bordered version
  36. //
  37. // Add 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. // Zebra-striping
  52. //
  53. // Default zebra-stripe styles (alternating gray and transparent backgrounds)
  54. .table-striped {
  55. tbody tr:nth-of-type(odd) {
  56. background-color: $table-accent-bg;
  57. }
  58. }
  59. // Hover effect
  60. //
  61. // Placed here since it has to come after the potential zebra striping
  62. .table-hover {
  63. tbody tr {
  64. @include hover {
  65. background-color: $table-hover-bg;
  66. }
  67. }
  68. }
  69. // Table backgrounds
  70. //
  71. // Exact selectors below required to override `.table-striped` and prevent
  72. // inheritance to nested tables.
  73. @each $color, $value in $theme-colors {
  74. @include table-row-variant($color, theme-color-level($color, -9));
  75. }
  76. @include table-row-variant(active, $table-active-bg);
  77. // Dark styles
  78. //
  79. // Same table markup, but inverted color scheme: dark background and light text.
  80. // stylelint-disable-next-line no-duplicate-selectors
  81. .table {
  82. .thead-dark {
  83. th {
  84. color: $table-dark-color;
  85. background-color: $table-dark-bg;
  86. border-color: $table-dark-border-color;
  87. }
  88. }
  89. .thead-light {
  90. th {
  91. color: $table-head-color;
  92. background-color: $table-head-bg;
  93. border-color: $table-border-color;
  94. }
  95. }
  96. }
  97. .table-dark {
  98. color: $table-dark-color;
  99. background-color: $table-dark-bg;
  100. th,
  101. td,
  102. thead th {
  103. border-color: $table-dark-border-color;
  104. }
  105. &.table-bordered {
  106. border: 0;
  107. }
  108. &.table-striped {
  109. tbody tr:nth-of-type(odd) {
  110. background-color: $table-dark-accent-bg;
  111. }
  112. }
  113. &.table-hover {
  114. tbody tr {
  115. @include hover {
  116. background-color: $table-dark-hover-bg;
  117. }
  118. }
  119. }
  120. }
  121. // Responsive tables
  122. //
  123. // Generate series of `.table-responsive-*` classes for configuring the screen
  124. // size of where your table will overflow.
  125. .table-responsive {
  126. @each $breakpoint in map-keys($grid-breakpoints) {
  127. $next: breakpoint-next($breakpoint, $grid-breakpoints);
  128. $infix: breakpoint-infix($next, $grid-breakpoints);
  129. &#{$infix} {
  130. @include media-breakpoint-down($breakpoint) {
  131. display: block;
  132. width: 100%;
  133. overflow-x: auto;
  134. -webkit-overflow-scrolling: touch;
  135. -ms-overflow-style: -ms-autohiding-scrollbar; // See https://github.com/twbs/bootstrap/pull/10057
  136. // Prevent double border on horizontal scroll due to use of `display: block;`
  137. &.table-bordered {
  138. border: 0;
  139. }
  140. }
  141. }
  142. }
  143. }