No Description
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.

_card.scss 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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#flexbug-4
  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. // The child selector allows nested `.card` within `.card-group`
  142. // to display properly.
  143. > .card {
  144. margin-bottom: $card-group-margin;
  145. }
  146. @include media-breakpoint-up(sm) {
  147. flex-flow: row wrap;
  148. // The child selector allows nested `.card` within `.card-group`
  149. // to display properly.
  150. > .card {
  151. // Flexbugs #4: https://github.com/philipwalton/flexbugs#flexbug-4
  152. flex: 1 0 0%;
  153. margin-bottom: 0;
  154. + .card {
  155. margin-left: 0;
  156. border-left: 0;
  157. }
  158. // Handle rounded corners
  159. @if $enable-rounded {
  160. &:first-child {
  161. @include border-right-radius(0);
  162. .card-img-top,
  163. .card-header {
  164. border-top-right-radius: 0;
  165. }
  166. .card-img-bottom,
  167. .card-footer {
  168. border-bottom-right-radius: 0;
  169. }
  170. }
  171. &:last-child {
  172. @include border-left-radius(0);
  173. .card-img-top,
  174. .card-header {
  175. border-top-left-radius: 0;
  176. }
  177. .card-img-bottom,
  178. .card-footer {
  179. border-bottom-left-radius: 0;
  180. }
  181. }
  182. &:only-child {
  183. @include border-radius($card-border-radius);
  184. .card-img-top,
  185. .card-header {
  186. @include border-top-radius($card-border-radius);
  187. }
  188. .card-img-bottom,
  189. .card-footer {
  190. @include border-bottom-radius($card-border-radius);
  191. }
  192. }
  193. &:not(:first-child):not(:last-child):not(:only-child) {
  194. @include border-radius(0);
  195. .card-img-top,
  196. .card-img-bottom,
  197. .card-header,
  198. .card-footer {
  199. @include border-radius(0);
  200. }
  201. }
  202. }
  203. }
  204. }
  205. }
  206. //
  207. // Columns
  208. //
  209. .card-columns {
  210. .card {
  211. margin-bottom: $card-columns-margin;
  212. }
  213. @include media-breakpoint-up(sm) {
  214. column-count: $card-columns-count;
  215. column-gap: $card-columns-gap;
  216. orphans: 1;
  217. widows: 1;
  218. .card {
  219. display: inline-block; // Don't let them vertically span multiple columns
  220. width: 100%; // Don't let their width change
  221. }
  222. }
  223. }
  224. //
  225. // Accordion
  226. //
  227. .accordion {
  228. .card:not(:first-of-type):not(:last-of-type) {
  229. border-bottom: 0;
  230. border-radius: 0;
  231. }
  232. .card:not(:first-of-type) {
  233. .card-header:first-child {
  234. border-radius: 0;
  235. }
  236. }
  237. .card:first-of-type {
  238. border-bottom: 0;
  239. border-bottom-right-radius: 0;
  240. border-bottom-left-radius: 0;
  241. }
  242. .card:last-of-type {
  243. border-top-left-radius: 0;
  244. border-top-right-radius: 0;
  245. }
  246. }