_card.scss 5.8 KB

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