card.md 25 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
### Kitchen sink
Mark Otto's avatar
cards  
Mark Otto committed
94

95
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
96
97

{% example html %}
98
99
<div class="card" style="width: 20rem;">
  <img class="card-img-top" data-src="holder.js/100px180/?text=Image cap" alt="Card image cap">
100
  <div class="card-body">
101
102
103
104
105
106
107
108
    <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>
109
  <div class="card-body">
110
111
112
    <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
113
114
115
</div>
{% endexample %}

116
### Header and footer
Mark Otto's avatar
cards  
Mark Otto committed
117
118
119
120
121
122
123
124

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

{% example html %}
<div class="card">
  <div class="card-header">
    Featured
  </div>
125
  <div class="card-body">
126
127
    <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>
128
129
130
131
132
    <a href="#" class="btn btn-primary">Go somewhere</a>
  </div>
</div>
{% endexample %}

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

135
136
{% example html %}
<div class="card">
137
  <h4 class="card-header">Featured</h4>
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
    <a href="#" class="btn btn-primary">Go somewhere</a>
  </div>
Mark Otto's avatar
cards  
Mark Otto committed
143
</div>
Mark Otto's avatar
Mark Otto committed
144
{% endexample %}
Mark Otto's avatar
cards  
Mark Otto committed
145

Mark Otto's avatar
Mark Otto committed
146
{% example html %}
Mark Otto's avatar
cards  
Mark Otto committed
147
148
149
150
<div class="card">
  <div class="card-header">
    Quote
  </div>
151
  <div class="card-body">
152
    <blockquote class="blockquote mb-0">
153
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
154
      <footer class="blockquote-footer">Someone famous in <cite title="Source Title">Source Title</cite></footer>
155
156
    </blockquote>
  </div>
Mark Otto's avatar
cards  
Mark Otto committed
157
158
159
160
</div>
{% endexample %}

{% example html %}
161
<div class="card text-center">
Mark Otto's avatar
cards  
Mark Otto committed
162
163
164
  <div class="card-header">
    Featured
  </div>
165
  <div class="card-body">
166
167
168
169
    <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
170
171
172
173
174
175
  <div class="card-footer text-muted">
    2 days ago
  </div>
</div>
{% endexample %}

176
## Sizing
177

178
179
180
181
182
183
184
185
186
187
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">
188
      <div class="card-body">
189
        <h4 class="card-title">Special title treatment</h4>
190
191
192
193
194
195
196
        <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">
197
      <div class="card-body">
198
        <h4 class="card-title">Special title treatment</h4>
199
200
201
202
203
204
205
206
207
208
        <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
209
Use our handful of [available sizing utilities]({{ site.baseurl }}/docs/{{ site.docs_version }}/utilities/sizing/) to quickly set a card's width.
210
211
212

{% example html %}
<div class="card w-75">
213
  <div class="card-body">
214
    <h4 class="card-title">Card title</h4>
215
216
217
218
219
220
    <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">
221
  <div class="card-body">
222
    <h4 class="card-title">Card title</h4>
223
224
225
226
227
228
229
230
231
232
233
234
    <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;">
235
  <div class="card-body">
236
    <h4 class="card-title">Special title treatment</h4>
237
238
239
240
241
    <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 %}
242

243
244
## Text alignment

245
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).
246
247
248

{% example html %}
<div class="card" style="width: 20rem;">
249
  <div class="card-body">
250
251
252
253
254
255
256
    <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;">
257
  <div class="card-body">
258
259
260
261
262
263
264
    <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;">
265
  <div class="card-body">
266
267
268
269
270
271
    <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
272
273
274

## Navigation

Mark Otto's avatar
Mark Otto committed
275
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
276

277
{% example html %}
278
<div class="card text-center">
279
  <div class="card-header">
280
    <ul class="nav nav-tabs card-header-tabs">
281
282
283
284
285
286
287
288
289
290
291
      <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>
292
  <div class="card-body">
293
294
295
296
297
298
299
300
    <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 %}
301
<div class="card text-center">
302
  <div class="card-header">
303
    <ul class="nav nav-pills card-header-pills">
304
305
306
307
308
309
310
311
312
313
314
      <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>
315
  <div class="card-body">
316
317
318
319
320
321
322
    <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 %}

323
## Images
Mark Otto's avatar
cards  
Mark Otto committed
324

325
326
327
328
329
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
330
331

{% example html %}
332
<div class="card mb-3">
XhmikosR's avatar
XhmikosR committed
333
  <img class="card-img-top" data-src="holder.js/100px180/" alt="Card image cap">
334
  <div class="card-body">
335
336
337
338
    <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
339
340
</div>
<div class="card">
341
  <div class="card-body">
342
343
344
345
    <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
346
  <img class="card-img-bottom" data-src="holder.js/100px180/" alt="Card image cap">
Mark Otto's avatar
cards  
Mark Otto committed
347
348
349
</div>
{% endexample %}

350
### Image overlays
Mark Otto's avatar
cards  
Mark Otto committed
351

Mark Otto's avatar
Mark Otto committed
352
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
353
354

{% example html %}
355
<div class="card bg-dark text-white">
XhmikosR's avatar
XhmikosR committed
356
  <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
357
358
359
  <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
360
    <p class="card-text">Last updated 3 mins ago</p>
Mark Otto's avatar
cards  
Mark Otto committed
361
362
363
364
  </div>
</div>
{% endexample %}

365
366
367
368
## Card styles

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

369
### Background and color
Mark Otto's avatar
cards  
Mark Otto committed
370

371
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
372
373

{% example html %}
374
375
{% 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
376
  <div class="card-header">Header</div>
377
  <div class="card-body">
378
379
    <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>
380
  </div>
381
</div>{% endfor %}
Mark Otto's avatar
cards  
Mark Otto committed
382
383
{% endexample %}

384
385
{% capture callout-include %}{% include callout-warning-color-assistive-technologies.md %}{% endcapture %}
{{ callout-include | markdownify }}
Mark Otto's avatar
cards  
Mark Otto committed
386

387
388
389
### 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
390
391

{% example html %}
392
393
394
395
396
397
{% 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
398
  </div>
399
</div>{% endfor %}
petetnt's avatar
petetnt committed
400
401
{% endexample %}

402
### Mixins utilities
403

404
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
405
406

{% example html %}
407
408
409
410
411
<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>
412
  </div>
413
  <div class="card-footer bg-transparent border-success">Footer</div>
Mark Otto's avatar
cards  
Mark Otto committed
414
415
416
</div>
{% endexample %}

417
## Card layout
Mark Otto's avatar
cards  
Mark Otto committed
418

419
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
420

421
422
423
### 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.
424

Mark Otto's avatar
cards  
Mark Otto committed
425
426
427
{% example html %}
<div class="card-group">
  <div class="card">
XhmikosR's avatar
XhmikosR committed
428
    <img class="card-img-top" data-src="holder.js/100px180/" alt="Card image cap">
429
    <div class="card-body">
430
431
432
433
      <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
434
435
  </div>
  <div class="card">
XhmikosR's avatar
XhmikosR committed
436
    <img class="card-img-top" data-src="holder.js/100px180/" alt="Card image cap">
437
    <div class="card-body">
438
439
440
441
      <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
442
443
  </div>
  <div class="card">
XhmikosR's avatar
XhmikosR committed
444
    <img class="card-img-top" data-src="holder.js/100px180/" alt="Card image cap">
445
    <div class="card-body">
446
447
448
449
      <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
450
451
452
453
  </div>
</div>
{% endexample %}

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

Mark Otto's avatar
Mark Otto committed
456
457
458
459
{% example html %}
<div class="card-group">
  <div class="card">
    <img class="card-img-top" data-src="holder.js/100px180/" alt="Card image cap">
460
    <div class="card-body">
Mark Otto's avatar
Mark Otto committed
461
462
463
464
465
466
467
468
469
      <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">
470
    <div class="card-body">
Mark Otto's avatar
Mark Otto committed
471
472
473
474
475
476
477
478
479
      <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">
480
    <div class="card-body">
Mark Otto's avatar
Mark Otto committed
481
482
483
484
485
486
487
488
489
      <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 %}
490

Mark Otto's avatar
Mark Otto committed
491
492
### Card decks

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

Mark Otto's avatar
cards  
Mark Otto committed
495
{% example html %}
496
497
498
<div class="card-deck">
  <div class="card">
    <img class="card-img-top" data-src="holder.js/100px200/" alt="Card image cap">
499
    <div class="card-body">
500
501
502
      <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
503
    </div>
504
505
506
  </div>
  <div class="card">
    <img class="card-img-top" data-src="holder.js/100px200/" alt="Card image cap">
507
    <div class="card-body">
508
509
510
      <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
511
    </div>
512
513
514
  </div>
  <div class="card">
    <img class="card-img-top" data-src="holder.js/100px200/" alt="Card image cap">
515
    <div class="card-body">
516
517
518
      <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
519
520
521
522
523
    </div>
  </div>
</div>
{% endexample %}

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

Mark Otto's avatar
Mark Otto committed
526
527
528
529
{% example html %}
<div class="card-deck">
  <div class="card">
    <img class="card-img-top" data-src="holder.js/100px180/" alt="Card image cap">
530
    <div class="card-body">
Mark Otto's avatar
Mark Otto committed
531
532
533
534
535
536
537
538
539
      <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">
540
    <div class="card-body">
Mark Otto's avatar
Mark Otto committed
541
542
543
544
545
546
547
548
549
      <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">
550
    <div class="card-body">
Mark Otto's avatar
Mark Otto committed
551
552
553
554
555
556
557
558
559
      <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 %}
560

561
562
### Card columns

XhmikosR's avatar
XhmikosR committed
563
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.
564
565

**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.
566

Mark Otto's avatar
cards  
Mark Otto committed
567
568
569
{% example html %}
<div class="card-columns">
  <div class="card">
Mark Otto's avatar
Mark Otto committed
570
    <img class="card-img-top" data-src="holder.js/100px160/" alt="Card image cap">
571
    <div class="card-body">
572
573
574
      <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
575
  </div>
576
  <div class="card p-3">
577
    <blockquote class="blockquote mb-0 card-body">
Mark Otto's avatar
cards  
Mark Otto committed
578
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
579
      <footer class="blockquote-footer">
580
581
582
583
        <small class="text-muted">
          Someone famous in <cite title="Source Title">Source Title</cite>
        </small>
      </footer>
Mark Otto's avatar
cards  
Mark Otto committed
584
585
586
    </blockquote>
  </div>
  <div class="card">
Mark Otto's avatar
Mark Otto committed
587
    <img class="card-img-top" data-src="holder.js/100px160/" alt="Card image cap">
588
    <div class="card-body">
589
590
591
592
      <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
593
  </div>
594
  <div class="card bg-primary text-white text-center p-3">
595
    <blockquote class="blockquote mb-0">
596
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat.</p>
597
      <footer class="blockquote-footer">
598
599
600
601
        <small>
          Someone famous in <cite title="Source Title">Source Title</cite>
        </small>
      </footer>
Mark Otto's avatar
cards  
Mark Otto committed
602
603
    </blockquote>
  </div>
604
  <div class="card text-center">
605
    <div class="card-body">
606
607
608
609
      <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
610
  </div>
611
  <div class="card">
Mark Otto's avatar
Mark Otto committed
612
    <img class="card-img" data-src="holder.js/100px260/" alt="Card image">
613
  </div>
614
  <div class="card p-3 text-right">
615
    <blockquote class="blockquote mb-0">
Mark Otto's avatar
cards  
Mark Otto committed
616
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
617
      <footer class="blockquote-footer">
618
619
620
621
        <small class="text-muted">
          Someone famous in <cite title="Source Title">Source Title</cite>
        </small>
      </footer>
Mark Otto's avatar
cards  
Mark Otto committed
622
623
    </blockquote>
  </div>
624
  <div class="card">
625
    <div class="card-body">
626
627
628
629
      <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
630
631
632
  </div>
</div>
{% endexample %}
633
634
635
636
637
638
639
640
641
642
643
644
645

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 %}