_card.scss 4.6 KB

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