_card.scss 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. //
  2. // Base styles
  3. //
  4. .card {
  5. position: relative;
  6. display: flex;
  7. flex-direction: column;
  8. min-width: 0;
  9. word-wrap: break-word;
  10. background-color: $card-bg;
  11. background-clip: border-box;
  12. border: $card-border-width solid $card-border-color;
  13. @include border-radius($card-border-radius);
  14. > hr {
  15. margin-right: 0;
  16. margin-left: 0;
  17. }
  18. > .list-group:first-child {
  19. .list-group-item:first-child {
  20. @include border-top-radius($card-border-radius);
  21. }
  22. }
  23. > .list-group:last-child {
  24. .list-group-item:last-child {
  25. @include border-bottom-radius($card-border-radius);
  26. }
  27. }
  28. }
  29. .card-body {
  30. // Enable `flex-grow: 1` for decks and groups so that card blocks take up
  31. // as much space as possible, ensuring footers are aligned to the bottom.
  32. flex: 1 1 auto;
  33. padding: $card-spacer-x;
  34. }
  35. .card-title {
  36. margin-bottom: $card-spacer-y;
  37. }
  38. .card-subtitle {
  39. margin-top: -($card-spacer-y / 2);
  40. margin-bottom: 0;
  41. }
  42. .card-text:last-child {
  43. margin-bottom: 0;
  44. }
  45. .card-link {
  46. @include hover {
  47. text-decoration: none;
  48. }
  49. + .card-link {
  50. margin-left: $card-spacer-x;
  51. }
  52. }
  53. //
  54. // Optional textual caps
  55. //
  56. .card-header {
  57. padding: $card-spacer-y $card-spacer-x;
  58. margin-bottom: 0; // Removes the default margin-bottom of <hN>
  59. background-color: $card-cap-bg;
  60. border-bottom: $card-border-width solid $card-border-color;
  61. &:first-child {
  62. @include border-radius($card-inner-border-radius $card-inner-border-radius 0 0);
  63. }
  64. + .list-group {
  65. .list-group-item:first-child {
  66. border-top: 0;
  67. }
  68. }
  69. }
  70. .card-footer {
  71. padding: $card-spacer-y $card-spacer-x;
  72. background-color: $card-cap-bg;
  73. border-top: $card-border-width solid $card-border-color;
  74. &:last-child {
  75. @include border-radius(0 0 $card-inner-border-radius $card-inner-border-radius);
  76. }
  77. }
  78. //
  79. // Header navs
  80. //
  81. .card-header-tabs {
  82. margin-right: -($card-spacer-x / 2);
  83. margin-bottom: -$card-spacer-y;
  84. margin-left: -($card-spacer-x / 2);
  85. border-bottom: 0;
  86. }
  87. .card-header-pills {
  88. margin-right: -($card-spacer-x / 2);
  89. margin-left: -($card-spacer-x / 2);
  90. }
  91. // Card image
  92. .card-img-overlay {
  93. position: absolute;
  94. top: 0;
  95. right: 0;
  96. bottom: 0;
  97. left: 0;
  98. padding: $card-img-overlay-padding;
  99. }
  100. .card-img {
  101. width: 100%; // Required because we use flexbox and this inherently applies align-self: stretch
  102. @include border-radius($card-inner-border-radius);
  103. }
  104. // Card image caps
  105. .card-img-top {
  106. width: 100%; // Required because we use flexbox and this inherently applies align-self: stretch
  107. @include border-top-radius($card-inner-border-radius);
  108. }
  109. .card-img-bottom {
  110. width: 100%; // Required because we use flexbox and this inherently applies align-self: stretch
  111. @include border-bottom-radius($card-inner-border-radius);
  112. }
  113. // Card deck
  114. .card-deck {
  115. display: flex;
  116. flex-direction: column;
  117. .card {
  118. margin-bottom: $card-deck-margin;
  119. }
  120. @include media-breakpoint-up(sm) {
  121. flex-flow: row wrap;
  122. margin-right: -$card-deck-margin;
  123. margin-left: -$card-deck-margin;
  124. .card {
  125. display: flex;
  126. // Flexbugs #4: https://github.com/philipwalton/flexbugs#4-flex-shorthand-declarations-with-unitless-flex-basis-values-are-ignored
  127. flex: 1 0 0%;
  128. flex-direction: column;
  129. margin-right: $card-deck-margin;
  130. margin-bottom: 0; // Override the default
  131. margin-left: $card-deck-margin;
  132. }
  133. }
  134. }
  135. //
  136. // Card groups
  137. //
  138. .card-group {
  139. display: flex;
  140. flex-direction: column;
  141. .card {
  142. margin-bottom: $card-group-margin;
  143. }
  144. @include media-breakpoint-up(sm) {
  145. flex-flow: row wrap;
  146. .card {
  147. // Flexbugs #4: https://github.com/philipwalton/flexbugs#4-flex-shorthand-declarations-with-unitless-flex-basis-values-are-ignored
  148. flex: 1 0 0%;
  149. margin-bottom: 0;
  150. + .card {
  151. margin-left: 0;
  152. border-left: 0;
  153. }
  154. // Handle rounded corners
  155. @if $enable-rounded {
  156. &:first-child {
  157. @include border-right-radius(0);
  158. .card-img-top {
  159. border-top-right-radius: 0;
  160. }
  161. .card-img-bottom {
  162. border-bottom-right-radius: 0;
  163. }
  164. }
  165. &:last-child {
  166. @include border-left-radius(0);
  167. .card-img-top {
  168. border-top-left-radius: 0;
  169. }
  170. .card-img-bottom {
  171. border-bottom-left-radius: 0;
  172. }
  173. }
  174. &:only-child {
  175. @include border-radius($card-border-radius);
  176. .card-img-top {
  177. @include border-top-radius($card-border-radius);
  178. }
  179. .card-img-bottom {
  180. @include border-bottom-radius($card-border-radius);
  181. }
  182. }
  183. &:not(:first-child):not(:last-child):not(:only-child) {
  184. border-radius: 0;
  185. .card-img-top,
  186. .card-img-bottom {
  187. border-radius: 0;
  188. }
  189. }
  190. }
  191. }
  192. }
  193. }
  194. //
  195. // Columns
  196. //
  197. .card-columns {
  198. .card {
  199. margin-bottom: $card-columns-margin;
  200. }
  201. @include media-breakpoint-up(sm) {
  202. column-count: $card-columns-count;
  203. column-gap: $card-columns-gap;
  204. .card {
  205. display: inline-block; // Don't let them vertically span multiple columns
  206. width: 100%; // Don't let their width change
  207. }
  208. }
  209. }