card.md 25.3 KB
Newer Older
Mark Otto's avatar
cards  
Mark Otto committed
1
---
Mark Otto's avatar
Mark Otto committed
2
layout: docs
Mark Otto's avatar
cards  
Mark Otto committed
3
title: Cards
Quy's avatar
Quy committed
4
description: Bootstrap's cards provide a flexible and extensible content container with multiple variants and options.
5
group: components
Mark Otto's avatar
Mark Otto committed
6
toc: true
Mark Otto's avatar
cards  
Mark Otto committed
7
8
---

Mark Otto's avatar
Mark Otto committed
9
10
## About

Mark Otto's avatar
cards  
Mark Otto committed
11
12
A **card** is a flexible and extensible content container. It includes options for headers and footers, a wide variety of content, contextual background colors, and powerful display options.

Mark Otto's avatar
Mark Otto committed
13
If you're familiar with Bootstrap 3, cards replace our old panels, wells, and thumbnails. Similar functionality to those components is available as modifier classes for cards.
Mark Otto's avatar
cards  
Mark Otto committed
14

15
## Example
Mark Otto's avatar
cards  
Mark Otto committed
16

Mark Otto's avatar
Mark Otto committed
17
18
Cards are built with as little markup and styles as possible, but still manage to deliver a ton of control and customization. Built with flexbox, they offer easy alignment and mix well with other Bootstrap components.

Quy's avatar
Quy committed
19
Below is an example of a basic card with mixed content and a fixed width. Cards have no fixed width to start, so they'll naturally fill the full width of its parent element. This is easily customized with our various [sizing options](#sizing).
Mark Otto's avatar
cards  
Mark Otto committed
20
21

{% example html %}
Mark Otto's avatar
Mark Otto committed
22
<div class="card" style="width: 20rem;">
XhmikosR's avatar
XhmikosR committed
23
  <img class="card-img-top" data-src="holder.js/100px180/" alt="Card image cap">
24
  <div class="card-body">
25
26
    <h4 class="card-title">Card title</h4>
    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
27
    <a href="#" class="btn btn-primary">Go somewhere</a>
28
  </div>
Mark Otto's avatar
cards  
Mark Otto committed
29
30
31
</div>
{% endexample %}

32
## Content types
Mark Otto's avatar
Mark Otto committed
33

34
Cards support a wide variety of content, including images, text, list groups, links, and more. Below are examples of what's supported.
Mark Otto's avatar
Mark Otto committed
35

36
### Body
Mark Otto's avatar
Mark Otto committed
37

38
The building block of a card is the `.card-body`. Use it whenever you need a padded section within a card.
39

40
41
{% example html %}
<div class="card">
42
  <div class="card-body">
43
    This is some text within a card body.
44
  </div>
Mark Otto's avatar
Mark Otto committed
45
</div>
46
47
{% endexample %}

48
### Titles, text, and links
49

XhmikosR's avatar
XhmikosR committed
50
Card titles are used by adding `.card-title` to a `<h*>` tag. In the same way, links are added and placed next to each other by adding `.card-link` to an `<a>` tag.
51

52
Subtitles are used by adding a `.card-subtitle` to a `<h*>` tag. If the `.card-title` and the `.card-subtitle` items are placed in a `.card-body` item, the card title and subtitle are aligned nicely.
53

54
{% example html %}
55
<div class="card" style="width: 20rem;">
56
  <div class="card-body">
57
    <h4 class="card-title">Card title</h4>
58
    <h6 class="card-subtitle mb-2 text-muted">Card subtitle</h6>
59
60
61
62
    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
    <a href="#" class="card-link">Card link</a>
    <a href="#" class="card-link">Another link</a>
  </div>
Mark Otto's avatar
Mark Otto committed
63
64
65
</div>
{% endexample %}

66
### Images
67

68
`.card-img-top` places an image to the top of the card. With `.card-text`, text can be added to the card. Text within `.card-text` can also be styled with the standard HTML tags.
Mark Otto's avatar
Mark Otto committed
69

Mark Otto's avatar
Mark Otto committed
70
{% example html %}
71
<div class="card" style="width: 20rem;">
72
  <img class="card-img-top" data-src="holder.js/100px180/?text=Image cap" alt="Card image cap">
73
  <div class="card-body">
74
    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
Mark Otto's avatar
Mark Otto committed
75
76
77
78
  </div>
</div>
{% endexample %}

79
80
81
### List groups

Create lists of content in a card with a flush list group.
Mark Otto's avatar
Mark Otto committed
82
83

{% example html %}
84
<div class="card" style="width: 20rem;">
85
86
87
88
89
  <ul class="list-group list-group-flush">
    <li class="list-group-item">Cras justo odio</li>
    <li class="list-group-item">Dapibus ac facilisis in</li>
    <li class="list-group-item">Vestibulum at eros</li>
  </ul>
Mark Otto's avatar
Mark Otto committed
90
91
92
</div>
{% endexample %}

93
94
95
96
97
98
99
100
101
102
103
104
105
{% example html %}
<div class="card" style="width: 20rem;">
  <div class="card-header">
    Featured
  </div>
  <ul class="list-group list-group-flush">
    <li class="list-group-item">Cras justo odio</li>
    <li class="list-group-item">Dapibus ac facilisis in</li>
    <li class="list-group-item">Vestibulum at eros</li>
  </ul>
</div>
{% endexample %}

106
### Kitchen sink
Mark Otto's avatar
cards  
Mark Otto committed
107

108
Mix and match multiple content types to create the card you need, or throw everything in there. Shown below are image styles, blocks, text styles, and a list group—all wrapped in a fixed-width card.
Mark Otto's avatar
cards  
Mark Otto committed
109
110

{% example html %}
111
112
<div class="card" style="width: 20rem;">
  <img class="card-img-top" data-src="holder.js/100px180/?text=Image cap" alt="Card image cap">
113
  <div class="card-body">
114
115
116
117
118
119
120
121
    <h4 class="card-title">Card title</h4>
    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
  </div>
  <ul class="list-group list-group-flush">
    <li class="list-group-item">Cras justo odio</li>
    <li class="list-group-item">Dapibus ac facilisis in</li>
    <li class="list-group-item">Vestibulum at eros</li>
  </ul>
122
  <div class="card-body">
123
124
125
    <a href="#" class="card-link">Card link</a>
    <a href="#" class="card-link">Another link</a>
  </div>
Mark Otto's avatar
cards  
Mark Otto committed
126
127
128
</div>
{% endexample %}

129
### Header and footer
Mark Otto's avatar
cards  
Mark Otto committed
130
131
132
133
134
135
136
137

Add an optional header and/or footer within a card.

{% example html %}
<div class="card">
  <div class="card-header">
    Featured
  </div>
138
  <div class="card-body">
139
140
    <h4 class="card-title">Special title treatment</h4>
    <p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
141
142
143
144
145
    <a href="#" class="btn btn-primary">Go somewhere</a>
  </div>
</div>
{% endexample %}

146
147
Card headers can be styled by adding `.card-header` to `<h*>` elements.

148
149
{% example html %}
<div class="card">
150
  <h4 class="card-header">Featured</h4>
151
  <div class="card-body">
152
153
    <h4 class="card-title">Special title treatment</h4>
    <p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
154
155
    <a href="#" class="btn btn-primary">Go somewhere</a>
  </div>
Mark Otto's avatar
cards  
Mark Otto committed
156
</div>
Mark Otto's avatar
Mark Otto committed
157
{% endexample %}
Mark Otto's avatar
cards  
Mark Otto committed
158

Mark Otto's avatar
Mark Otto committed
159
{% example html %}
Mark Otto's avatar
cards  
Mark Otto committed
160
161
162
163
<div class="card">
  <div class="card-header">
    Quote
  </div>
164
  <div class="card-body">
165
    <blockquote class="blockquote mb-0">
166
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
167
      <footer class="blockquote-footer">Someone famous in <cite title="Source Title">Source Title</cite></footer>
168
169
    </blockquote>
  </div>
Mark Otto's avatar
cards  
Mark Otto committed
170
171
172
173
</div>
{% endexample %}

{% example html %}
174
<div class="card text-center">
Mark Otto's avatar
cards  
Mark Otto committed
175
176
177
  <div class="card-header">
    Featured
  </div>
178
  <div class="card-body">
179
180
181
182
    <h4 class="card-title">Special title treatment</h4>
    <p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
    <a href="#" class="btn btn-primary">Go somewhere</a>
  </div>
Mark Otto's avatar
cards  
Mark Otto committed
183
184
185
186
187
188
  <div class="card-footer text-muted">
    2 days ago
  </div>
</div>
{% endexample %}

189
## Sizing
190

191
192
193
194
195
196
197
198
199
200
Cards assume no specific `width` to start, so they'll be 100% wide unless otherwise stated. You can change this as needed with custom CSS, grid classes, grid Sass mixins, or utilities.

### Using grid markup

Using the grid, wrap cards in columns and rows as needed.

{% example html %}
<div class="row">
  <div class="col-sm-6">
    <div class="card">
201
      <div class="card-body">
202
        <h4 class="card-title">Special title treatment</h4>
203
204
205
206
207
208
209
        <p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
        <a href="#" class="btn btn-primary">Go somewhere</a>
      </div>
    </div>
  </div>
  <div class="col-sm-6">
    <div class="card">
210
      <div class="card-body">
211
        <h4 class="card-title">Special title treatment</h4>
212
213
214
215
216
217
218
219
220
221
        <p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
        <a href="#" class="btn btn-primary">Go somewhere</a>
      </div>
    </div>
  </div>
</div>
{% endexample %}

### Using utilities

Mark Otto's avatar
Mark Otto committed
222
Use our handful of [available sizing utilities]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/sizing/) to quickly set a card's width.
223
224
225

{% example html %}
<div class="card w-75">
226
  <div class="card-body">
227
    <h4 class="card-title">Card title</h4>
228
229
230
231
232
233
    <p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
    <a href="#" class="btn btn-primary">Button</a>
  </div>
</div>

<div class="card w-50">
234
  <div class="card-body">
235
    <h4 class="card-title">Card title</h4>
236
237
238
239
240
241
242
243
244
245
246
247
    <p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
    <a href="#" class="btn btn-primary">Button</a>
  </div>
</div>
{% endexample %}

### Using custom CSS

Use custom CSS in your stylesheets or as inline styles to set a width.

{% example html %}
<div class="card" style="width: 20rem;">
248
  <div class="card-body">
249
    <h4 class="card-title">Special title treatment</h4>
250
251
252
253
254
    <p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
    <a href="#" class="btn btn-primary">Go somewhere</a>
  </div>
</div>
{% endexample %}
255

256
257
## Text alignment

258
You can quickly change the text alignment of any card—in its entirety or specific parts—with our [text align classes]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/text/#text-alignment).
259
260
261

{% example html %}
<div class="card" style="width: 20rem;">
262
  <div class="card-body">
263
264
265
266
267
268
269
    <h4 class="card-title">Special title treatment</h4>
    <p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
    <a href="#" class="btn btn-primary">Go somewhere</a>
  </div>
</div>

<div class="card text-center" style="width: 20rem;">
270
  <div class="card-body">
271
272
273
274
275
276
277
    <h4 class="card-title">Special title treatment</h4>
    <p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
    <a href="#" class="btn btn-primary">Go somewhere</a>
  </div>
</div>

<div class="card text-right" style="width: 20rem;">
278
  <div class="card-body">
279
280
281
282
283
284
    <h4 class="card-title">Special title treatment</h4>
    <p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
    <a href="#" class="btn btn-primary">Go somewhere</a>
  </div>
</div>
{% endexample %}
Mark Otto's avatar
Mark Otto committed
285
286
287

## Navigation

Mark Otto's avatar
Mark Otto committed
288
Add some navigation to a card's header (or block) with Bootstrap's [nav components]({{ site.baseurl }}/docs/{{ site.docs_version }}/components/navs/).
Mark Otto's avatar
Mark Otto committed
289

290
{% example html %}
291
<div class="card text-center">
292
  <div class="card-header">
293
    <ul class="nav nav-tabs card-header-tabs">
294
295
296
297
298
299
300
301
302
303
304
      <li class="nav-item">
        <a class="nav-link active" href="#">Active</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Link</a>
      </li>
      <li class="nav-item">
        <a class="nav-link disabled" href="#">Disabled</a>
      </li>
    </ul>
  </div>
305
  <div class="card-body">
306
307
308
309
310
311
312
313
    <h4 class="card-title">Special title treatment</h4>
    <p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
    <a href="#" class="btn btn-primary">Go somewhere</a>
  </div>
</div>
{% endexample %}

{% example html %}
314
<div class="card text-center">
315
  <div class="card-header">
316
    <ul class="nav nav-pills card-header-pills">
317
318
319
320
321
322
323
324
325
326
327
      <li class="nav-item">
        <a class="nav-link active" href="#">Active</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Link</a>
      </li>
      <li class="nav-item">
        <a class="nav-link disabled" href="#">Disabled</a>
      </li>
    </ul>
  </div>
328
  <div class="card-body">
329
330
331
332
333
334
335
    <h4 class="card-title">Special title treatment</h4>
    <p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
    <a href="#" class="btn btn-primary">Go somewhere</a>
  </div>
</div>
{% endexample %}

336
## Images
Mark Otto's avatar
cards  
Mark Otto committed
337

338
339
340
341
342
Cards include a few options for working with images. Choose from appending "image caps" at either end of a card, overlaying images with card content, or simply embedding the image in a card.

### Image caps

Similar to headers and footers, cards can include top and bottom "image caps"—images at the top or bottom of a card.
Mark Otto's avatar
cards  
Mark Otto committed
343
344

{% example html %}
345
<div class="card mb-3">
XhmikosR's avatar
XhmikosR committed
346
  <img class="card-img-top" data-src="holder.js/100px180/" alt="Card image cap">
347
  <div class="card-body">
348
349
350
351
    <h4 class="card-title">Card title</h4>
    <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
    <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
  </div>
Mark Otto's avatar
cards  
Mark Otto committed
352
353
</div>
<div class="card">
354
  <div class="card-body">
355
356
357
358
    <h4 class="card-title">Card title</h4>
    <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
    <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
  </div>
XhmikosR's avatar
XhmikosR committed
359
  <img class="card-img-bottom" data-src="holder.js/100px180/" alt="Card image cap">
Mark Otto's avatar
cards  
Mark Otto committed
360
361
362
</div>
{% endexample %}

363
### Image overlays
Mark Otto's avatar
cards  
Mark Otto committed
364

Mark Otto's avatar
Mark Otto committed
365
Turn an image into a card background and overlay your card's text. Depending on the image, you may or may not need additional styles or utilities.
Mark Otto's avatar
cards  
Mark Otto committed
366
367

{% example html %}
368
<div class="card bg-dark text-white">
XhmikosR's avatar
XhmikosR committed
369
  <img class="card-img" data-src="holder.js/100px270/#55595c:#373a3c/text:Card image" alt="Card image">
Mark Otto's avatar
cards  
Mark Otto committed
370
371
372
  <div class="card-img-overlay">
    <h4 class="card-title">Card title</h4>
    <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
Mark Otto's avatar
Mark Otto committed
373
    <p class="card-text">Last updated 3 mins ago</p>
Mark Otto's avatar
cards  
Mark Otto committed
374
375
376
377
  </div>
</div>
{% endexample %}

378
379
380
381
## Card styles

Cards include various options for customizing their backgrounds, borders, and color.

382
### Background and color
Mark Otto's avatar
cards  
Mark Otto committed
383

384
Use [text and background utilities]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/colors/) to change the appearance of a card.
Mark Otto's avatar
cards  
Mark Otto committed
385
386

{% example html %}
387
388
{% for color in site.data.theme-colors %}
<div class="card{% unless color.name == "light" %} text-white{% endunless %} bg-{{ color.name }} mb-3" style="max-width: 20rem;">
Mark Otto's avatar
Mark Otto committed
389
  <div class="card-header">Header</div>
390
  <div class="card-body">
391
392
    <h4 class="card-title">{{ color.name | capitalize }} card title</h4>
    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
393
  </div>
394
</div>{% endfor %}
Mark Otto's avatar
cards  
Mark Otto committed
395
396
{% endexample %}

397
398
{% capture callout-include %}{% include callout-warning-color-assistive-technologies.md %}{% endcapture %}
{{ callout-include | markdownify }}
Mark Otto's avatar
cards  
Mark Otto committed
399

400
401
402
### Border

Use [border utilities]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/borders/) to change just the `border-color` of a card. Note that you can put `.text-{color}` classes on the parent `.card` or a subset of the card's contents as shown below.
Mark Otto's avatar
cards  
Mark Otto committed
403
404

{% example html %}
405
406
407
408
409
410
{% for color in site.data.theme-colors %}
<div class="card border-{{ color.name }} mb-3" style="max-width: 20rem;">
  <div class="card-header">Header</div>
  <div class="card-body{% unless color.name == "light" %} text-{{ color.name }}{% endunless %}">
    <h4 class="card-title">{{ color.name | capitalize }} card title</h4>
    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
petetnt's avatar
petetnt committed
411
  </div>
412
</div>{% endfor %}
petetnt's avatar
petetnt committed
413
414
{% endexample %}

415
### Mixins utilities
416

417
You can also change the borders on the card header and footer as needed, and even remove their `background-color` with `.bg-transparent`.
petetnt's avatar
petetnt committed
418
419

{% example html %}
420
421
422
423
424
<div class="card border-success mb-3" style="max-width: 20rem;">
  <div class="card-header bg-transparent border-success">Header</div>
  <div class="card-body text-success">
    <h4 class="card-title">Success card title</h4>
    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
425
  </div>
426
  <div class="card-footer bg-transparent border-success">Footer</div>
Mark Otto's avatar
cards  
Mark Otto committed
427
428
429
</div>
{% endexample %}

430
## Card layout
Mark Otto's avatar
cards  
Mark Otto committed
431

432
In addition to styling the content within cards, Bootstrap includes a few options for laying out series of cards. For the time being, **these layout options are not yet responsive**.
Mark Otto's avatar
cards  
Mark Otto committed
433

434
435
436
### Card groups

Use card groups to render cards as a single, attached element with equal width and height columns. Card groups use `display: flex;` to achieve their uniform sizing.
437

Mark Otto's avatar
cards  
Mark Otto committed
438
439
440
{% example html %}
<div class="card-group">
  <div class="card">
XhmikosR's avatar
XhmikosR committed
441
    <img class="card-img-top" data-src="holder.js/100px180/" alt="Card image cap">
442
    <div class="card-body">
443
444
445
446
      <h4 class="card-title">Card title</h4>
      <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
      <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
    </div>
Mark Otto's avatar
cards  
Mark Otto committed
447
448
  </div>
  <div class="card">
XhmikosR's avatar
XhmikosR committed
449
    <img class="card-img-top" data-src="holder.js/100px180/" alt="Card image cap">
450
    <div class="card-body">
451
452
453
454
      <h4 class="card-title">Card title</h4>
      <p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
      <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
    </div>
Mark Otto's avatar
cards  
Mark Otto committed
455
456
  </div>
  <div class="card">
XhmikosR's avatar
XhmikosR committed
457
    <img class="card-img-top" data-src="holder.js/100px180/" alt="Card image cap">
458
    <div class="card-body">
459
460
461
462
      <h4 class="card-title">Card title</h4>
      <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.</p>
      <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
    </div>
Mark Otto's avatar
cards  
Mark Otto committed
463
464
465
466
  </div>
</div>
{% endexample %}

467
When using card groups with footers, their content will automatically line up.
Mark Otto's avatar
cards  
Mark Otto committed
468

Mark Otto's avatar
Mark Otto committed
469
470
471
472
{% example html %}
<div class="card-group">
  <div class="card">
    <img class="card-img-top" data-src="holder.js/100px180/" alt="Card image cap">
473
    <div class="card-body">
Mark Otto's avatar
Mark Otto committed
474
475
476
477
478
479
480
481
482
      <h4 class="card-title">Card title</h4>
      <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
    </div>
    <div class="card-footer">
      <small class="text-muted">Last updated 3 mins ago</small>
    </div>
  </div>
  <div class="card">
    <img class="card-img-top" data-src="holder.js/100px180/" alt="Card image cap">
483
    <div class="card-body">
Mark Otto's avatar
Mark Otto committed
484
485
486
487
488
489
490
491
492
      <h4 class="card-title">Card title</h4>
      <p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
    </div>
    <div class="card-footer">
      <small class="text-muted">Last updated 3 mins ago</small>
    </div>
  </div>
  <div class="card">
    <img class="card-img-top" data-src="holder.js/100px180/" alt="Card image cap">
493
    <div class="card-body">
Mark Otto's avatar
Mark Otto committed
494
495
496
497
498
499
500
501
502
      <h4 class="card-title">Card title</h4>
      <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.</p>
    </div>
    <div class="card-footer">
      <small class="text-muted">Last updated 3 mins ago</small>
    </div>
  </div>
</div>
{% endexample %}
503

Mark Otto's avatar
Mark Otto committed
504
505
### Card decks

506
Need a set of equal width and height cards that aren't attached to one another? Use card decks.
507

Mark Otto's avatar
cards  
Mark Otto committed
508
{% example html %}
509
510
511
<div class="card-deck">
  <div class="card">
    <img class="card-img-top" data-src="holder.js/100px200/" alt="Card image cap">
512
    <div class="card-body">
513
514
515
      <h4 class="card-title">Card title</h4>
      <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
      <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
Mark Otto's avatar
cards  
Mark Otto committed
516
    </div>
517
518
519
  </div>
  <div class="card">
    <img class="card-img-top" data-src="holder.js/100px200/" alt="Card image cap">
520
    <div class="card-body">
521
522
523
      <h4 class="card-title">Card title</h4>
      <p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
      <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
Mark Otto's avatar
cards  
Mark Otto committed
524
    </div>
525
526
527
  </div>
  <div class="card">
    <img class="card-img-top" data-src="holder.js/100px200/" alt="Card image cap">
528
    <div class="card-body">
529
530
531
      <h4 class="card-title">Card title</h4>
      <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.</p>
      <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
Mark Otto's avatar
cards  
Mark Otto committed
532
533
534
535
536
    </div>
  </div>
</div>
{% endexample %}

Mark Otto's avatar
Mark Otto committed
537
Just like with card groups, card footers in decks will automatically line up.
Mark Otto's avatar
cards  
Mark Otto committed
538

Mark Otto's avatar
Mark Otto committed
539
540
541
542
{% example html %}
<div class="card-deck">
  <div class="card">
    <img class="card-img-top" data-src="holder.js/100px180/" alt="Card image cap">
543
    <div class="card-body">
Mark Otto's avatar
Mark Otto committed
544
545
546
547
548
549
550
551
552
      <h4 class="card-title">Card title</h4>
      <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
    </div>
    <div class="card-footer">
      <small class="text-muted">Last updated 3 mins ago</small>
    </div>
  </div>
  <div class="card">
    <img class="card-img-top" data-src="holder.js/100px180/" alt="Card image cap">
553
    <div class="card-body">
Mark Otto's avatar
Mark Otto committed
554
555
556
557
558
559
560
561
562
      <h4 class="card-title">Card title</h4>
      <p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
    </div>
    <div class="card-footer">
      <small class="text-muted">Last updated 3 mins ago</small>
    </div>
  </div>
  <div class="card">
    <img class="card-img-top" data-src="holder.js/100px180/" alt="Card image cap">
563
    <div class="card-body">
Mark Otto's avatar
Mark Otto committed
564
565
566
567
568
569
570
571
572
      <h4 class="card-title">Card title</h4>
      <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.</p>
    </div>
    <div class="card-footer">
      <small class="text-muted">Last updated 3 mins ago</small>
    </div>
  </div>
</div>
{% endexample %}
573

574
575
### Card columns

XhmikosR's avatar
XhmikosR committed
576
Cards can be organized into [Masonry](https://masonry.desandro.com/)-like columns with just CSS by wrapping them in `.card-columns`. Cards are built with CSS `column` properties instead of flexbox for easier alignment. Cards are ordered from top to bottom and left to right.
577
578

**Heads up!** Your mileage with card columns may vary. To prevent cards breaking across columns, we must set them to `display: inline-block` as `column-break-inside: avoid` isn't a bulletproof solution yet.
579

Mark Otto's avatar
cards  
Mark Otto committed
580
581
582
{% example html %}
<div class="card-columns">
  <div class="card">
Mark Otto's avatar
Mark Otto committed
583
    <img class="card-img-top" data-src="holder.js/100px160/" alt="Card image cap">
584
    <div class="card-body">
585
586
587
      <h4 class="card-title">Card title that wraps to a new line</h4>
      <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
    </div>
Mark Otto's avatar
cards  
Mark Otto committed
588
  </div>
589
  <div class="card p-3">
590
    <blockquote class="blockquote mb-0 card-body">
Mark Otto's avatar
cards  
Mark Otto committed
591
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
592
      <footer class="blockquote-footer">
593
594
595
596
        <small class="text-muted">
          Someone famous in <cite title="Source Title">Source Title</cite>
        </small>
      </footer>
Mark Otto's avatar
cards  
Mark Otto committed
597
598
599
    </blockquote>
  </div>
  <div class="card">
Mark Otto's avatar
Mark Otto committed
600
    <img class="card-img-top" data-src="holder.js/100px160/" alt="Card image cap">
601
    <div class="card-body">
602
603
604
605
      <h4 class="card-title">Card title</h4>
      <p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
      <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
    </div>
Mark Otto's avatar
cards  
Mark Otto committed
606
  </div>
607
  <div class="card bg-primary text-white text-center p-3">
608
    <blockquote class="blockquote mb-0">
609
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat.</p>
610
      <footer class="blockquote-footer">
611
612
613
614
        <small>
          Someone famous in <cite title="Source Title">Source Title</cite>
        </small>
      </footer>
Mark Otto's avatar
cards  
Mark Otto committed
615
616
    </blockquote>
  </div>
617
  <div class="card text-center">
618
    <div class="card-body">
619
620
621
622
      <h4 class="card-title">Card title</h4>
      <p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
      <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
    </div>
Mark Otto's avatar
cards  
Mark Otto committed
623
  </div>
624
  <div class="card">
Mark Otto's avatar
Mark Otto committed
625
    <img class="card-img" data-src="holder.js/100px260/" alt="Card image">
626
  </div>
627
  <div class="card p-3 text-right">
628
    <blockquote class="blockquote mb-0">
Mark Otto's avatar
cards  
Mark Otto committed
629
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
630
      <footer class="blockquote-footer">
631
632
633
634
        <small class="text-muted">
          Someone famous in <cite title="Source Title">Source Title</cite>
        </small>
      </footer>
Mark Otto's avatar
cards  
Mark Otto committed
635
636
    </blockquote>
  </div>
637
  <div class="card">
638
    <div class="card-body">
639
640
641
642
      <h4 class="card-title">Card title</h4>
      <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.</p>
      <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
    </div>
Mark Otto's avatar
cards  
Mark Otto committed
643
644
645
  </div>
</div>
{% endexample %}
646
647
648
649
650
651
652
653
654
655
656
657
658

Card columns can also be extended and customized with some additional code. Shown below is an extension of the `.card-columns` class using the same CSS we use—CSS columns— to generate a set of responsive tiers for changing the number of columns.

{% highlight scss %}
.card-columns {
  @include media-breakpoint-only(lg) {
    column-count: 4;
  }
  @include media-breakpoint-only(xl) {
    column-count: 5;
  }
}
{% endhighlight %}