UNPKG

5.69 kBSCSSView Raw
1//
2// Base styles
3//
4
5.card {
6 position: relative;
7 display: flex;
8 flex-direction: column;
9 min-width: 0; // See https://github.com/twbs/bootstrap/pull/22740#issuecomment-305868106
10 height: $card-height;
11 word-wrap: break-word;
12 background-color: $card-bg;
13 background-clip: border-box;
14 border: $card-border-width solid $card-border-color;
15 @include border-radius($card-border-radius);
16
17 > hr {
18 margin-right: 0;
19 margin-left: 0;
20 }
21
22 > .list-group {
23 border-top: inherit;
24 border-bottom: inherit;
25
26 &:first-child {
27 border-top-width: 0;
28 @include border-top-radius($card-inner-border-radius);
29 }
30
31 &:last-child {
32 border-bottom-width: 0;
33 @include border-bottom-radius($card-inner-border-radius);
34 }
35 }
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
49.card-title {
50 margin-bottom: $card-spacer-y;
51}
52
53.card-subtitle {
54 margin-top: -$card-spacer-y / 2;
55 margin-bottom: 0;
56}
57
58.card-text:last-child {
59 margin-bottom: 0;
60}
61
62.card-link {
63 @include hover() {
64 text-decoration: none;
65 }
66
67 + .card-link {
68 margin-left: $card-spacer-x;
69 }
70}
71
72//
73// Optional textual caps
74//
75
76.card-header {
77 padding: $card-spacer-y $card-spacer-x;
78 margin-bottom: 0; // Removes the default margin-bottom of <hN>
79 color: $card-cap-color;
80 background-color: $card-cap-bg;
81 border-bottom: $card-border-width solid $card-border-color;
82
83 &:first-child {
84 @include border-radius($card-inner-border-radius $card-inner-border-radius 0 0);
85 }
86
87 + .list-group {
88 .list-group-item:first-child {
89 border-top: 0;
90 }
91 }
92}
93
94.card-footer {
95 padding: $card-spacer-y $card-spacer-x;
96 color: $card-cap-color;
97 background-color: $card-cap-bg;
98 border-top: $card-border-width solid $card-border-color;
99
100 &:last-child {
101 @include border-radius(0 0 $card-inner-border-radius $card-inner-border-radius);
102 }
103}
104
105
106//
107// Header navs
108//
109
110.card-header-tabs {
111 margin-right: -$card-spacer-x / 2;
112 margin-bottom: -$card-spacer-y;
113 margin-left: -$card-spacer-x / 2;
114 border-bottom: 0;
115}
116
117.card-header-pills {
118 margin-right: -$card-spacer-x / 2;
119 margin-left: -$card-spacer-x / 2;
120}
121
122// Card image
123.card-img-overlay {
124 position: absolute;
125 top: 0;
126 right: 0;
127 bottom: 0;
128 left: 0;
129 padding: $card-img-overlay-padding;
130}
131
132.card-img,
133.card-img-top,
134.card-img-bottom {
135 flex-shrink: 0; // For IE: https://github.com/twbs/bootstrap/issues/29396
136 width: 100%; // Required because we use flexbox and this inherently applies align-self: stretch
137}
138
139.card-img,
140.card-img-top {
141 @include border-top-radius($card-inner-border-radius);
142}
143
144.card-img,
145.card-img-bottom {
146 @include border-bottom-radius($card-inner-border-radius);
147}
148
149
150// Card deck
151
152.card-deck {
153 .card {
154 margin-bottom: $card-deck-margin;
155 }
156
157 @include media-breakpoint-up(sm) {
158 display: flex;
159 flex-flow: row wrap;
160 margin-right: -$card-deck-margin;
161 margin-left: -$card-deck-margin;
162
163 .card {
164 // Flexbugs #4: https://github.com/philipwalton/flexbugs#flexbug-4
165 flex: 1 0 0%;
166 margin-right: $card-deck-margin;
167 margin-bottom: 0; // Override the default
168 margin-left: $card-deck-margin;
169 }
170 }
171}
172
173
174//
175// Card groups
176//
177
178.card-group {
179 // The child selector allows nested `.card` within `.card-group`
180 // to display properly.
181 > .card {
182 margin-bottom: $card-group-margin;
183 }
184
185 @include media-breakpoint-up(sm) {
186 display: flex;
187 flex-flow: row wrap;
188 // The child selector allows nested `.card` within `.card-group`
189 // to display properly.
190 > .card {
191 // Flexbugs #4: https://github.com/philipwalton/flexbugs#flexbug-4
192 flex: 1 0 0%;
193 margin-bottom: 0;
194
195 + .card {
196 margin-left: 0;
197 border-left: 0;
198 }
199
200 // Handle rounded corners
201 @if $enable-rounded {
202 &:not(:last-child) {
203 @include border-right-radius(0);
204
205 .card-img-top,
206 .card-header {
207 // stylelint-disable-next-line property-blacklist
208 border-top-right-radius: 0;
209 }
210 .card-img-bottom,
211 .card-footer {
212 // stylelint-disable-next-line property-blacklist
213 border-bottom-right-radius: 0;
214 }
215 }
216
217 &:not(:first-child) {
218 @include border-left-radius(0);
219
220 .card-img-top,
221 .card-header {
222 // stylelint-disable-next-line property-blacklist
223 border-top-left-radius: 0;
224 }
225 .card-img-bottom,
226 .card-footer {
227 // stylelint-disable-next-line property-blacklist
228 border-bottom-left-radius: 0;
229 }
230 }
231 }
232 }
233 }
234}
235
236
237//
238// Columns
239//
240
241.card-columns {
242 .card {
243 margin-bottom: $card-columns-margin;
244 }
245
246 @include media-breakpoint-up(sm) {
247 column-count: $card-columns-count;
248 column-gap: $card-columns-gap;
249 orphans: 1;
250 widows: 1;
251
252 .card {
253 display: inline-block; // Don't let them vertically span multiple columns
254 width: 100%; // Don't let their width change
255 }
256 }
257}
258
259
260//
261// Accordion
262//
263
264.accordion {
265 > .card {
266 overflow: hidden;
267
268 &:not(:last-of-type) {
269 border-bottom: 0;
270 @include border-bottom-radius(0);
271 }
272
273 &:not(:first-of-type) {
274 @include border-top-radius(0);
275 }
276
277 > .card-header {
278 @include border-radius(0);
279 margin-bottom: -$card-border-width;
280 }
281 }
282}