card.md 28.6 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
Mark Otto committed
11
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. 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
12

13
## Example
Mark Otto's avatar
cards  
Mark Otto committed
14

XhmikosR's avatar
XhmikosR committed
15
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. They have no `margin` by default, so use [spacing utilities]({{< docsref "/utilities/spacing" >}}) as needed.
Mark Otto's avatar
Mark Otto committed
16

Quy's avatar
Quy committed
17
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
18

XhmikosR's avatar
XhmikosR committed
19
{{< example >}}
20
<div class="card" style="width: 18rem;">
XhmikosR's avatar
XhmikosR committed
21
  {{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
22
  <div class="card-body">
23
    <h5 class="card-title">Card title</h5>
24
    <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>
25
    <a href="#" class="btn btn-primary">Go somewhere</a>
26
  </div>
Mark Otto's avatar
cards  
Mark Otto committed
27
</div>
XhmikosR's avatar
XhmikosR committed
28
{{< /example >}}
Mark Otto's avatar
cards  
Mark Otto committed
29

30
## Content types
Mark Otto's avatar
Mark Otto committed
31

32
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
33

34
### Body
Mark Otto's avatar
Mark Otto committed
35

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

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

46
### Titles, text, and links
47

XhmikosR's avatar
XhmikosR committed
48
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.
49

50
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.
51

XhmikosR's avatar
XhmikosR committed
52
{{< example >}}
53
<div class="card" style="width: 18rem;">
54
  <div class="card-body">
55
    <h5 class="card-title">Card title</h5>
56
    <h6 class="card-subtitle mb-2 text-muted">Card subtitle</h6>
57
58
59
60
    <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
61
</div>
XhmikosR's avatar
XhmikosR committed
62
{{< /example >}}
Mark Otto's avatar
Mark Otto committed
63

64
### Images
65

66
`.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
67

XhmikosR's avatar
XhmikosR committed
68
{{< example >}}
69
<div class="card" style="width: 18rem;">
XhmikosR's avatar
XhmikosR committed
70
  {{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
71
  <div class="card-body">
72
    <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
73
74
  </div>
</div>
XhmikosR's avatar
XhmikosR committed
75
{{< /example >}}
Mark Otto's avatar
Mark Otto committed
76

77
78
79
### List groups

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

XhmikosR's avatar
XhmikosR committed
81
{{< example >}}
82
<div class="card" style="width: 18rem;">
83
84
85
86
87
  <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
88
</div>
XhmikosR's avatar
XhmikosR committed
89
{{< /example >}}
Mark Otto's avatar
Mark Otto committed
90

XhmikosR's avatar
XhmikosR committed
91
{{< example >}}
92
<div class="card" style="width: 18rem;">
93
94
95
96
97
98
99
100
101
  <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>
XhmikosR's avatar
XhmikosR committed
102
{{< /example >}}
103

104
### Kitchen sink
Mark Otto's avatar
cards  
Mark Otto committed
105

106
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
107

XhmikosR's avatar
XhmikosR committed
108
{{< example >}}
109
<div class="card" style="width: 18rem;">
XhmikosR's avatar
XhmikosR committed
110
  {{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
111
  <div class="card-body">
112
    <h5 class="card-title">Card title</h5>
113
114
115
116
117
118
119
    <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>
120
  <div class="card-body">
121
122
123
    <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
124
</div>
XhmikosR's avatar
XhmikosR committed
125
{{< /example >}}
Mark Otto's avatar
cards  
Mark Otto committed
126

127
### Header and footer
Mark Otto's avatar
cards  
Mark Otto committed
128
129
130

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

XhmikosR's avatar
XhmikosR committed
131
{{< example >}}
Mark Otto's avatar
cards  
Mark Otto committed
132
133
134
135
<div class="card">
  <div class="card-header">
    Featured
  </div>
136
  <div class="card-body">
137
    <h5 class="card-title">Special title treatment</h5>
138
    <p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
139
140
141
    <a href="#" class="btn btn-primary">Go somewhere</a>
  </div>
</div>
XhmikosR's avatar
XhmikosR committed
142
{{< /example >}}
143

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

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

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

XhmikosR's avatar
XhmikosR committed
171
{{< example >}}
172
<div class="card text-center">
Mark Otto's avatar
cards  
Mark Otto committed
173
174
175
  <div class="card-header">
    Featured
  </div>
176
  <div class="card-body">
177
    <h5 class="card-title">Special title treatment</h5>
178
179
180
    <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
181
182
183
184
  <div class="card-footer text-muted">
    2 days ago
  </div>
</div>
XhmikosR's avatar
XhmikosR committed
185
{{< /example >}}
Mark Otto's avatar
cards  
Mark Otto committed
186

187
## Sizing
188

189
190
191
192
193
194
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.

XhmikosR's avatar
XhmikosR committed
195
{{< example >}}
196
197
198
<div class="row">
  <div class="col-sm-6">
    <div class="card">
199
      <div class="card-body">
200
        <h5 class="card-title">Special title treatment</h5>
201
202
203
204
205
206
207
        <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">
208
      <div class="card-body">
209
        <h5 class="card-title">Special title treatment</h5>
210
211
212
213
214
215
        <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>
XhmikosR's avatar
XhmikosR committed
216
{{< /example >}}
217
218
219

### Using utilities

XhmikosR's avatar
XhmikosR committed
220
Use our handful of [available sizing utilities]({{< docsref "/utilities/sizing" >}}) to quickly set a card's width.
221

XhmikosR's avatar
XhmikosR committed
222
{{< example >}}
223
<div class="card w-75">
224
  <div class="card-body">
225
    <h5 class="card-title">Card title</h5>
226
227
228
229
230
231
    <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">
232
  <div class="card-body">
233
    <h5 class="card-title">Card title</h5>
234
235
236
237
    <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>
XhmikosR's avatar
XhmikosR committed
238
{{< /example >}}
239
240
241
242
243

### Using custom CSS

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

XhmikosR's avatar
XhmikosR committed
244
{{< example >}}
245
<div class="card" style="width: 18rem;">
246
  <div class="card-body">
247
    <h5 class="card-title">Special title treatment</h5>
248
249
250
251
    <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>
XhmikosR's avatar
XhmikosR committed
252
{{< /example >}}
253

254
255
## Text alignment

XhmikosR's avatar
XhmikosR committed
256
You can quickly change the text alignment of any card—in its entirety or specific parts—with our [text align classes]({{< docsref "/utilities/text#text-alignment" >}}).
257

XhmikosR's avatar
XhmikosR committed
258
{{< example >}}
259
<div class="card" style="width: 18rem;">
260
  <div class="card-body">
261
    <h5 class="card-title">Special title treatment</h5>
262
263
264
265
266
    <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>

267
<div class="card text-center" style="width: 18rem;">
268
  <div class="card-body">
269
    <h5 class="card-title">Special title treatment</h5>
270
271
272
273
274
    <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>

275
<div class="card text-right" style="width: 18rem;">
276
  <div class="card-body">
277
    <h5 class="card-title">Special title treatment</h5>
278
279
280
281
    <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>
XhmikosR's avatar
XhmikosR committed
282
{{< /example >}}
Mark Otto's avatar
Mark Otto committed
283
284
285

## Navigation

XhmikosR's avatar
XhmikosR committed
286
Add some navigation to a card's header (or block) with Bootstrap's [nav components]({{< docsref "/components/navs" >}}).
Mark Otto's avatar
Mark Otto committed
287

XhmikosR's avatar
XhmikosR committed
288
{{< example >}}
289
<div class="card text-center">
290
  <div class="card-header">
291
    <ul class="nav nav-tabs card-header-tabs">
292
293
294
295
296
297
298
      <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">
299
        <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
300
301
302
      </li>
    </ul>
  </div>
303
  <div class="card-body">
304
    <h5 class="card-title">Special title treatment</h5>
305
306
307
308
    <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>
XhmikosR's avatar
XhmikosR committed
309
{{< /example >}}
310

XhmikosR's avatar
XhmikosR committed
311
{{< example >}}
312
<div class="card text-center">
313
  <div class="card-header">
314
    <ul class="nav nav-pills card-header-pills">
315
316
317
318
319
320
321
      <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">
322
        <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
323
324
325
      </li>
    </ul>
  </div>
326
  <div class="card-body">
327
    <h5 class="card-title">Special title treatment</h5>
328
329
330
331
    <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>
XhmikosR's avatar
XhmikosR committed
332
{{< /example >}}
333

334
## Images
Mark Otto's avatar
cards  
Mark Otto committed
335

336
337
338
339
340
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
341

XhmikosR's avatar
XhmikosR committed
342
{{< example >}}
343
<div class="card mb-3">
XhmikosR's avatar
XhmikosR committed
344
  {{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
345
  <div class="card-body">
346
    <h5 class="card-title">Card title</h5>
347
348
349
    <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
350
351
</div>
<div class="card">
352
  <div class="card-body">
353
    <h5 class="card-title">Card title</h5>
354
355
356
    <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
357
  {{< placeholder width="100%" height="180" class="card-img-bottom" text="Image cap" >}}
Mark Otto's avatar
cards  
Mark Otto committed
358
</div>
XhmikosR's avatar
XhmikosR committed
359
{{< /example >}}
Mark Otto's avatar
cards  
Mark Otto committed
360

361
### Image overlays
Mark Otto's avatar
cards  
Mark Otto committed
362

Mark Otto's avatar
Mark Otto committed
363
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
364

XhmikosR's avatar
XhmikosR committed
365
{{< example >}}
366
<div class="card bg-dark text-white">
XhmikosR's avatar
XhmikosR committed
367
  {{< placeholder width="100%" height="270" class="bd-placeholder-img-lg card-img" text="Card image" >}}
Mark Otto's avatar
cards  
Mark Otto committed
368
  <div class="card-img-overlay">
369
    <h5 class="card-title">Card title</h5>
Mark Otto's avatar
cards  
Mark Otto committed
370
    <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
371
    <p class="card-text">Last updated 3 mins ago</p>
Mark Otto's avatar
cards  
Mark Otto committed
372
373
  </div>
</div>
XhmikosR's avatar
XhmikosR committed
374
{{< /example >}}
375

XhmikosR's avatar
XhmikosR committed
376
{{< callout info >}}
377
Note that content should not be larger than the height of the image. If content is larger than the image the content will be displayed outside the image.
XhmikosR's avatar
XhmikosR committed
378
{{< /callout >}}
Mark Otto's avatar
cards  
Mark Otto committed
379

380
381
382
383
## Horizontal

Using a combination of grid and utility classes, cards can be made horizontal in a mobile-friendly and responsive way. In the example below, we remove the grid gutters with `.no-gutters` and use `.col-md-*` classes to make the card horizontal at the `md` breakpoint. Further adjustments may be needed depending on your card content.

XhmikosR's avatar
XhmikosR committed
384
{{< example >}}
385
386
387
<div class="card mb-3" style="max-width: 540px;">
  <div class="row no-gutters">
    <div class="col-md-4">
388
      {{< placeholder width="100%" height="250" text="Image" >}}
389
390
391
392
393
394
395
396
397
398
    </div>
    <div class="col-md-8">
      <div class="card-body">
        <h5 class="card-title">Card title</h5>
        <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>
    </div>
  </div>
</div>
XhmikosR's avatar
XhmikosR committed
399
{{< /example >}}
400

401
402
403
404
## Card styles

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

405
### Background and color
Mark Otto's avatar
cards  
Mark Otto committed
406

XhmikosR's avatar
XhmikosR committed
407
Use [text and background utilities]({{< docsref "/utilities/colors" >}}) to change the appearance of a card.
Mark Otto's avatar
cards  
Mark Otto committed
408

XhmikosR's avatar
XhmikosR committed
409
410
411
{{< example >}}
{{< card.inline >}}
{{- range (index $.Site.Data "theme-colors") }}
412
<div class="card{{ if not (or (eq .name "light") (eq .name "warning")) }} text-white{{ end }} bg-{{ .name }} mb-3" style="max-width: 18rem;">
Mark Otto's avatar
Mark Otto committed
413
  <div class="card-header">Header</div>
414
  <div class="card-body">
XhmikosR's avatar
XhmikosR committed
415
    <h5 class="card-title">{{ .name | title }} card title</h5>
416
    <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>
417
  </div>
XhmikosR's avatar
XhmikosR committed
418
419
420
421
</div>
{{- end -}}
{{< /card.inline >}}
{{< /example >}}
Mark Otto's avatar
cards  
Mark Otto committed
422

XhmikosR's avatar
XhmikosR committed
423
424
425
{{< callout info >}}
{{< partial "callout-warning-color-assistive-technologies.md" >}}
{{< /callout >}}
Mark Otto's avatar
cards  
Mark Otto committed
426

427
428
### Border

XhmikosR's avatar
XhmikosR committed
429
Use [border utilities]({{< docsref "/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
430

XhmikosR's avatar
XhmikosR committed
431
432
433
434
{{< example >}}
{{< card.inline >}}
{{- range (index $.Site.Data "theme-colors") }}
<div class="card border-{{ .name }} mb-3" style="max-width: 18rem;">
435
  <div class="card-header">Header</div>
XhmikosR's avatar
XhmikosR committed
436
437
  <div class="card-body{{ if not (eq .name "light") }} text-{{ .name }}{{ end }}">
    <h5 class="card-title">{{ .name | title }} card title</h5>
438
    <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
439
  </div>
XhmikosR's avatar
XhmikosR committed
440
441
442
443
</div>
{{- end -}}
{{< /card.inline >}}
{{< /example >}}
petetnt's avatar
petetnt committed
444

445
### Mixins utilities
446

447
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
448

XhmikosR's avatar
XhmikosR committed
449
{{< example >}}
450
<div class="card border-success mb-3" style="max-width: 18rem;">
451
452
  <div class="card-header bg-transparent border-success">Header</div>
  <div class="card-body text-success">
453
    <h5 class="card-title">Success card title</h5>
454
    <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>
455
  </div>
456
  <div class="card-footer bg-transparent border-success">Footer</div>
Mark Otto's avatar
cards  
Mark Otto committed
457
</div>
XhmikosR's avatar
XhmikosR committed
458
{{< /example >}}
Mark Otto's avatar
cards  
Mark Otto committed
459

460
## Card layout
Mark Otto's avatar
cards  
Mark Otto committed
461

462
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
463

464
465
466
### 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.
467

XhmikosR's avatar
XhmikosR committed
468
{{< example >}}
Mark Otto's avatar
cards  
Mark Otto committed
469
470
<div class="card-group">
  <div class="card">
XhmikosR's avatar
XhmikosR committed
471
    {{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
472
    <div class="card-body">
473
      <h5 class="card-title">Card title</h5>
474
475
476
      <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
477
478
  </div>
  <div class="card">
XhmikosR's avatar
XhmikosR committed
479
    {{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
480
    <div class="card-body">
481
      <h5 class="card-title">Card title</h5>
482
483
484
      <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
485
486
  </div>
  <div class="card">
XhmikosR's avatar
XhmikosR committed
487
    {{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
488
    <div class="card-body">
489
      <h5 class="card-title">Card title</h5>
490
491
492
      <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
493
494
  </div>
</div>
XhmikosR's avatar
XhmikosR committed
495
{{< /example >}}
Mark Otto's avatar
cards  
Mark Otto committed
496

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

XhmikosR's avatar
XhmikosR committed
499
{{< example >}}
Mark Otto's avatar
Mark Otto committed
500
501
<div class="card-group">
  <div class="card">
XhmikosR's avatar
XhmikosR committed
502
    {{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
503
    <div class="card-body">
504
      <h5 class="card-title">Card title</h5>
Mark Otto's avatar
Mark Otto committed
505
506
507
508
509
510
511
      <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">
XhmikosR's avatar
XhmikosR committed
512
    {{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
513
    <div class="card-body">
514
      <h5 class="card-title">Card title</h5>
Mark Otto's avatar
Mark Otto committed
515
516
517
518
519
520
521
      <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">
XhmikosR's avatar
XhmikosR committed
522
    {{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
523
    <div class="card-body">
524
      <h5 class="card-title">Card title</h5>
Mark Otto's avatar
Mark Otto committed
525
526
527
528
529
530
531
      <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>
XhmikosR's avatar
XhmikosR committed
532
{{< /example >}}
533

Mark Otto's avatar
Mark Otto committed
534
535
### Card decks

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

XhmikosR's avatar
XhmikosR committed
538
{{< example >}}
539
540
<div class="card-deck">
  <div class="card">
XhmikosR's avatar
XhmikosR committed
541
    {{< placeholder width="100%" height="200" class="card-img-top" text="Image cap" >}}
542
    <div class="card-body">
543
      <h5 class="card-title">Card title</h5>
544
545
      <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
546
    </div>
547
548
  </div>
  <div class="card">
XhmikosR's avatar
XhmikosR committed
549
    {{< placeholder width="100%" height="200" class="card-img-top" text="Image cap" >}}
550
    <div class="card-body">
551
      <h5 class="card-title">Card title</h5>
552
553
      <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
554
    </div>
555
556
  </div>
  <div class="card">
XhmikosR's avatar
XhmikosR committed
557
    {{< placeholder width="100%" height="200" class="card-img-top" text="Image cap" >}}
558
    <div class="card-body">
559
      <h5 class="card-title">Card title</h5>
560
561
      <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
562
563
564
    </div>
  </div>
</div>
XhmikosR's avatar
XhmikosR committed
565
{{< /example >}}
Mark Otto's avatar
cards  
Mark Otto committed
566

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

XhmikosR's avatar
XhmikosR committed
569
{{< example >}}
Mark Otto's avatar
Mark Otto committed
570
571
<div class="card-deck">
  <div class="card">
XhmikosR's avatar
XhmikosR committed
572
    {{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
573
    <div class="card-body">
574
      <h5 class="card-title">Card title</h5>
Mark Otto's avatar
Mark Otto committed
575
576
577
578
579
580
581
      <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">
XhmikosR's avatar
XhmikosR committed
582
    {{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
583
    <div class="card-body">
584
      <h5 class="card-title">Card title</h5>
Mark Otto's avatar
Mark Otto committed
585
586
587
588
589
590
591
      <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">
XhmikosR's avatar
XhmikosR committed
592
    {{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}
593
    <div class="card-body">
594
      <h5 class="card-title">Card title</h5>
Mark Otto's avatar
Mark Otto committed
595
596
597
598
599
600
601
      <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>
XhmikosR's avatar
XhmikosR committed
602
{{< /example >}}
603

Mark Otto's avatar
Mark Otto committed
604
605
### Grid cards

606
Use the Bootstrap grid system and its [`.row-cols` classes]({{< docsref "/layout/grid#row-columns" >}}) to control how many grid columns (wrapped around your cards) you show per row. For example, here's `.row-cols-1` laying out the cards on one column, and `.row-cols-md-2` splitting four cards to equal width across multiple rows, from the medium breakpoint up.
Mark Otto's avatar
Mark Otto committed
607
608

{{< example >}}
609
<div class="row row-cols-1 row-cols-md-2">
610
611
  <div class="col mb-4">
    <div class="card">
Mark Otto's avatar
Mark Otto committed
612
613
614
615
616
617
618
      {{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
      <div class="card-body">
        <h5 class="card-title">Card title</h5>
        <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>
    </div>
  </div>
619
620
  <div class="col mb-4">
    <div class="card">
Mark Otto's avatar
Mark Otto committed
621
622
623
624
625
626
627
      {{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
      <div class="card-body">
        <h5 class="card-title">Card title</h5>
        <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>
    </div>
  </div>
628
629
  <div class="col mb-4">
    <div class="card">
Mark Otto's avatar
Mark Otto committed
630
631
632
633
634
635
636
      {{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
      <div class="card-body">
        <h5 class="card-title">Card title</h5>
        <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content.</p>
      </div>
    </div>
  </div>
637
638
  <div class="col mb-4">
    <div class="card">
Mark Otto's avatar
Mark Otto committed
639
640
641
642
643
644
645
646
647
648
      {{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
      <div class="card-body">
        <h5 class="card-title">Card title</h5>
        <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>
    </div>
  </div>
</div>
{{< /example >}}

649
650
Change it to `.row-cols-3` and you'll see the fourth card wrap.

Mark Otto's avatar
Mark Otto committed
651
{{< example >}}
652
<div class="row row-cols-1 row-cols-md-3">
653
654
  <div class="col mb-4">
    <div class="card">
Mark Otto's avatar
Mark Otto committed
655
656
657
658
659
660
661
      {{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
      <div class="card-body">
        <h5 class="card-title">Card title</h5>
        <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>
    </div>
  </div>
662
663
  <div class="col mb-4">
    <div class="card">
Mark Otto's avatar
Mark Otto committed
664
665
666
667
668
669
670
      {{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
      <div class="card-body">
        <h5 class="card-title">Card title</h5>
        <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>
    </div>
  </div>
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
  <div class="col mb-4">
    <div class="card">
      {{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
      <div class="card-body">
        <h5 class="card-title">Card title</h5>
        <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content.</p>
      </div>
    </div>
  </div>
  <div class="col mb-4">
    <div class="card">
      {{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
      <div class="card-body">
        <h5 class="card-title">Card title</h5>
        <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>
    </div>
  </div>
</div>
{{< /example >}}

When you need equal height, add `.h-100` to the cards.

{{< example >}}
695
<div class="row row-cols-1 row-cols-md-3">
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
  <div class="col mb-4">
    <div class="card h-100">
      {{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
      <div class="card-body">
        <h5 class="card-title">Card title</h5>
        <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>
    </div>
  </div>
  <div class="col mb-4">
    <div class="card h-100">
      {{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
      <div class="card-body">
        <h5 class="card-title">Card title</h5>
        <p class="card-text">This is a short card.</p>
      </div>
    </div>
  </div>
  <div class="col mb-4">
    <div class="card h-100">
Mark Otto's avatar
Mark Otto committed
716
717
718
719
720
721
722
      {{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
      <div class="card-body">
        <h5 class="card-title">Card title</h5>
        <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content.</p>
      </div>
    </div>
  </div>
723
724
  <div class="col mb-4">
    <div class="card h-100">
Mark Otto's avatar
Mark Otto committed
725
726
727
728
729
730
731
732
733
734
735
      {{< placeholder width="100%" height="140" class="card-img-top" text="Image cap" >}}
      <div class="card-body">
        <h5 class="card-title">Card title</h5>
        <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>
    </div>
  </div>
</div>
{{< /example >}}

### Masonry
736

737
In `v4` we used a CSS-only technique to mimic the behavior of [Masonry](https://masonry.desandro.com/)-like columns, but this technique came with lots of unpleasant [side effects](https://github.com/twbs/bootstrap/pull/28922). If you want to have this type of layout in `v5`, you can just make use of Masonry plugin. **Masonry is not included in Bootstrap**, but we've made a [demo example]({{< docsref "/examples/masonry" >}}) to help you get started.