You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

216 lines
4.7 KiB

  1. //
  2. // Base styles
  3. //
  4. .card {
  5. position: relative;
  6. display: flex;
  7. flex-direction: column;
  8. min-width: 0; // See https://github.com/twbs/bootstrap/pull/22740#issuecomment-305868106
  9. height: $card-height;
  10. word-wrap: break-word;
  11. background-color: $card-bg;
  12. background-clip: border-box;
  13. border: $card-border-width solid $card-border-color;
  14. @include border-radius($card-border-radius);
  15. @include box-shadow($card-box-shadow);
  16. > hr {
  17. margin-right: 0;
  18. margin-left: 0;
  19. }
  20. > .list-group {
  21. border-top: inherit;
  22. border-bottom: inherit;
  23. &:first-child {
  24. border-top-width: 0;
  25. @include border-top-radius($card-inner-border-radius);
  26. }
  27. &:last-child {
  28. border-bottom-width: 0;
  29. @include border-bottom-radius($card-inner-border-radius);
  30. }
  31. }
  32. // Due to specificity of the above selector (`.card > .list-group`), we must
  33. // use a child selector here to prevent double borders.
  34. > .card-header + .list-group,
  35. > .list-group + .card-footer {
  36. border-top: 0;
  37. }
  38. }
  39. .card-body {
  40. // Enable `flex-grow: 1` for decks and groups so that card blocks take up
  41. // as much space as possible, ensuring footers are aligned to the bottom.
  42. flex: 1 1 auto;
  43. padding: $card-spacer-y $card-spacer-x;
  44. color: $card-color;
  45. }
  46. .card-title {
  47. margin-bottom: $card-title-spacer-y;
  48. }
  49. .card-subtitle {
  50. margin-top: -$card-title-spacer-y * .5;
  51. margin-bottom: 0;
  52. }
  53. .card-text:last-child {
  54. margin-bottom: 0;
  55. }
  56. .card-link {
  57. &:hover {
  58. text-decoration: if($link-hover-decoration == underline, none, null);
  59. }
  60. + .card-link {
  61. margin-left: $card-spacer-x;
  62. }
  63. }
  64. //
  65. // Optional textual caps
  66. //
  67. .card-header {
  68. padding: $card-cap-padding-y $card-cap-padding-x;
  69. margin-bottom: 0; // Removes the default margin-bottom of <hN>
  70. color: $card-cap-color;
  71. background-color: $card-cap-bg;
  72. border-bottom: $card-border-width solid $card-border-color;
  73. &:first-child {
  74. @include border-radius($card-inner-border-radius $card-inner-border-radius 0 0);
  75. }
  76. }
  77. .card-footer {
  78. padding: $card-cap-padding-y $card-cap-padding-x;
  79. color: $card-cap-color;
  80. background-color: $card-cap-bg;
  81. border-top: $card-border-width solid $card-border-color;
  82. &:last-child {
  83. @include border-radius(0 0 $card-inner-border-radius $card-inner-border-radius);
  84. }
  85. }
  86. //
  87. // Header navs
  88. //
  89. .card-header-tabs {
  90. margin-right: -$card-cap-padding-x * .5;
  91. margin-bottom: -$card-cap-padding-y;
  92. margin-left: -$card-cap-padding-x * .5;
  93. border-bottom: 0;
  94. @if $nav-tabs-link-active-bg != $card-bg {
  95. .nav-link.active {
  96. background-color: $card-bg;
  97. border-bottom-color: $card-bg;
  98. }
  99. }
  100. }
  101. .card-header-pills {
  102. margin-right: -$card-cap-padding-x * .5;
  103. margin-left: -$card-cap-padding-x * .5;
  104. }
  105. // Card image
  106. .card-img-overlay {
  107. position: absolute;
  108. top: 0;
  109. right: 0;
  110. bottom: 0;
  111. left: 0;
  112. padding: $card-img-overlay-padding;
  113. @include border-radius($card-inner-border-radius);
  114. }
  115. .card-img,
  116. .card-img-top,
  117. .card-img-bottom {
  118. width: 100%; // Required because we use flexbox and this inherently applies align-self: stretch
  119. }
  120. .card-img,
  121. .card-img-top {
  122. @include border-top-radius($card-inner-border-radius);
  123. }
  124. .card-img,
  125. .card-img-bottom {
  126. @include border-bottom-radius($card-inner-border-radius);
  127. }
  128. //
  129. // Card groups
  130. //
  131. .card-group {
  132. // The child selector allows nested `.card` within `.card-group`
  133. // to display properly.
  134. > .card {
  135. margin-bottom: $card-group-margin;
  136. }
  137. @include media-breakpoint-up(sm) {
  138. display: flex;
  139. flex-flow: row wrap;
  140. // The child selector allows nested `.card` within `.card-group`
  141. // to display properly.
  142. > .card {
  143. // Flexbugs #4: https://github.com/philipwalton/flexbugs#flexbug-4
  144. flex: 1 0 0%;
  145. margin-bottom: 0;
  146. + .card {
  147. margin-left: 0;
  148. border-left: 0;
  149. }
  150. // Handle rounded corners
  151. @if $enable-rounded {
  152. &:not(:last-child) {
  153. @include border-end-radius(0);
  154. .card-img-top,
  155. .card-header {
  156. // stylelint-disable-next-line property-disallowed-list
  157. border-top-right-radius: 0;
  158. }
  159. .card-img-bottom,
  160. .card-footer {
  161. // stylelint-disable-next-line property-disallowed-list
  162. border-bottom-right-radius: 0;
  163. }
  164. }
  165. &:not(:first-child) {
  166. @include border-start-radius(0);
  167. .card-img-top,
  168. .card-header {
  169. // stylelint-disable-next-line property-disallowed-list
  170. border-top-left-radius: 0;
  171. }
  172. .card-img-bottom,
  173. .card-footer {
  174. // stylelint-disable-next-line property-disallowed-list
  175. border-bottom-left-radius: 0;
  176. }
  177. }
  178. }
  179. }
  180. }
  181. }