_card.scss 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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:first-child {
  20. .list-group-item:first-child {
  21. @include border-top-radius($card-border-radius);
  22. }
  23. }
  24. > .list-group:last-child {
  25. .list-group-item:last-child {
  26. @include border-bottom-radius($card-border-radius);
  27. }
  28. }
  29. }
  30. .card-body {
  31. // Enable `flex-grow: 1` for decks and groups so that card blocks take up
  32. // as much space as possible, ensuring footers are aligned to the bottom.
  33. flex: 1 1 auto;
  34. // Workaround for the image size bug in IE
  35. // See: https://github.com/twbs/bootstrap/pull/28855
  36. min-height: 1px;
  37. padding: $card-spacer-x;
  38. color: $card-color;
  39. }
  40. .card-title {
  41. margin-bottom: $card-spacer-y;
  42. }
  43. .card-subtitle {
  44. margin-top: -$card-spacer-y / 2;
  45. margin-bottom: 0;
  46. }
  47. .card-text:last-child {
  48. margin-bottom: 0;
  49. }
  50. .card-link {
  51. @include hover() {
  52. text-decoration: none;
  53. }
  54. + .card-link {
  55. margin-left: $card-spacer-x;
  56. }
  57. }
  58. //
  59. // Optional textual caps
  60. //
  61. .card-header {
  62. padding: $card-spacer-y $card-spacer-x;
  63. margin-bottom: 0; // Removes the default margin-bottom of <hN>
  64. color: $card-cap-color;
  65. background-color: $card-cap-bg;
  66. border-bottom: $card-border-width solid $card-border-color;
  67. &:first-child {
  68. @include border-radius($card-inner-border-radius $card-inner-border-radius 0 0);
  69. }
  70. + .list-group {
  71. .list-group-item:first-child {
  72. border-top: 0;
  73. }
  74. }
  75. }
  76. .card-footer {
  77. padding: $card-spacer-y $card-spacer-x;
  78. background-color: $card-cap-bg;
  79. border-top: $card-border-width solid $card-border-color;
  80. &:last-child {
  81. @include border-radius(0 0 $card-inner-border-radius $card-inner-border-radius);
  82. }
  83. }
  84. //
  85. // Header navs
  86. //
  87. .card-header-tabs {
  88. margin-right: -$card-spacer-x / 2;
  89. margin-bottom: -$card-spacer-y;
  90. margin-left: -$card-spacer-x / 2;
  91. border-bottom: 0;
  92. }
  93. .card-header-pills {
  94. margin-right: -$card-spacer-x / 2;
  95. margin-left: -$card-spacer-x / 2;
  96. }
  97. // Card image
  98. .card-img-overlay {
  99. position: absolute;
  100. top: 0;
  101. right: 0;
  102. bottom: 0;
  103. left: 0;
  104. padding: $card-img-overlay-padding;
  105. }
  106. .card-img,
  107. .card-img-top,
  108. .card-img-bottom {
  109. flex-shrink: 0; // For IE: https://github.com/twbs/bootstrap/issues/29396
  110. width: 100%; // Required because we use flexbox and this inherently applies align-self: stretch
  111. }
  112. .card-img,
  113. .card-img-top {
  114. @include border-top-radius($card-inner-border-radius);
  115. }
  116. .card-img,
  117. .card-img-bottom {
  118. @include border-bottom-radius($card-inner-border-radius);
  119. }
  120. // Card deck
  121. .card-deck {
  122. .card {
  123. margin-bottom: $card-deck-margin;
  124. }
  125. @include media-breakpoint-up(sm) {
  126. display: flex;
  127. flex-flow: row wrap;
  128. margin-right: -$card-deck-margin;
  129. margin-left: -$card-deck-margin;
  130. .card {
  131. // Flexbugs #4: https://github.com/philipwalton/flexbugs#flexbug-4
  132. flex: 1 0 0%;
  133. margin-right: $card-deck-margin;
  134. margin-bottom: 0; // Override the default
  135. margin-left: $card-deck-margin;
  136. }
  137. }
  138. }
  139. //
  140. // Card groups
  141. //
  142. .card-group {
  143. // The child selector allows nested `.card` within `.card-group`
  144. // to display properly.
  145. > .card {
  146. margin-bottom: $card-group-margin;
  147. }
  148. @include media-breakpoint-up(sm) {
  149. display: flex;
  150. flex-flow: row wrap;
  151. // The child selector allows nested `.card` within `.card-group`
  152. // to display properly.
  153. > .card {
  154. // Flexbugs #4: https://github.com/philipwalton/flexbugs#flexbug-4
  155. flex: 1 0 0%;
  156. margin-bottom: 0;
  157. + .card {
  158. margin-left: 0;
  159. border-left: 0;
  160. }
  161. // Handle rounded corners
  162. @if $enable-rounded {
  163. &:not(:last-child) {
  164. @include border-right-radius(0);
  165. .card-img-top,
  166. .card-header {
  167. // stylelint-disable-next-line property-blacklist
  168. border-top-right-radius: 0;
  169. }
  170. .card-img-bottom,
  171. .card-footer {
  172. // stylelint-disable-next-line property-blacklist
  173. border-bottom-right-radius: 0;
  174. }
  175. }
  176. &:not(:first-child) {
  177. @include border-left-radius(0);
  178. .card-img-top,
  179. .card-header {
  180. // stylelint-disable-next-line property-blacklist
  181. border-top-left-radius: 0;
  182. }
  183. .card-img-bottom,
  184. .card-footer {
  185. // stylelint-disable-next-line property-blacklist
  186. border-bottom-left-radius: 0;
  187. }
  188. }
  189. }
  190. }
  191. }
  192. }
  193. //
  194. // Columns
  195. //
  196. .card-columns {
  197. .card {
  198. margin-bottom: $card-columns-margin;
  199. }
  200. @include media-breakpoint-up(sm) {
  201. column-count: $card-columns-count;
  202. column-gap: $card-columns-gap;
  203. orphans: 1;
  204. widows: 1;
  205. .card {
  206. display: inline-block; // Don't let them vertically span multiple columns
  207. width: 100%; // Don't let their width change
  208. }
  209. }
  210. }
  211. //
  212. // Accordion
  213. //
  214. .accordion {
  215. > .card {
  216. overflow: hidden;
  217. &:not(:last-of-type) {
  218. border-bottom: 0;
  219. @include border-bottom-radius(0);
  220. }
  221. &:not(:first-of-type) {
  222. @include border-top-radius(0);
  223. }
  224. > .card-header {
  225. @include border-radius(0);
  226. margin-bottom: -$card-border-width;
  227. }
  228. }
  229. }