1
0

_tables.scss 4.4 KB

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