Cards·续
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.
Card row
Use the .card-row class to make a card horizontal. For image caps, use the .card-img-start or .card-img-end class to position the image at the (inline) start or end position of the card.
<div class="card-body"> <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="fg-2">Last updated 3 mins ago</small></p> </div> </div>`} />
And with the reverse layout:
<div class="card-body"> <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="fg-2">Last updated 3 mins ago</small></p> </div> </div>`} />
Theme variants
Customize cards by using our theme color utilities. By default, cards use bg for their background and border colors when applying a theme color. Use .card-subtle to swap the background and border colors for a more subtle look.
<Example class="d-grid grid grid-cols-1 md:grid-cols-2 gap-4" code={getData('theme-colors').map((themeColor) => <div class="card theme-${themeColor.name}">
<div class="card-header">${themeColor.title}</div>
<div class="card-body">
<h4 class="card-title">Card title</h4>
<p class="card-text">Card text…</p>
</div>
</div>)} customMarkup={getData('theme-colors').map((themeColor) => <div class="card theme-${themeColor.name}">…</div>)} />
<Example class="d-grid grid grid-cols-1 md:grid-cols-2 gap-4" code={getData('theme-colors').map((themeColor) => <div class="card card-subtle theme-${themeColor.name}">
<div class="card-header">${themeColor.title}</div>
<div class="card-body">
<h4 class="card-title">Card title</h4>
<p class="card-text">Card text…</p>
</div>
</div>)} customMarkup={getData('theme-colors').map((themeColor) => <div class="card card-subtle theme-${themeColor.name}">…</div>)} />
Translucent cards
Add .card-translucent to blur and saturate the background of a card. Header and footer backgrounds are also adjusted for a consistent look.
<div class="card-body"> <h4 class="card-title">Translucent card</h4> <p class="card-text">This card has a translucent background with a backdrop blur effect.</p> <a href="#" class="btn-solid theme-primary">Go somewhere</a> </div> </div>`} />
<div class="card-header"> Featured </div> <div class="card-body"> <h4 class="card-title">Card with header</h4> <p class="card-text">Headers and footers are also made translucent to maintain a consistent look.</p> <a href="#" class="btn-solid theme-primary">Go somewhere</a> </div> <div class="card-footer fg-2"> 2 days ago </div> </div>`} />
Card layout
In addition to styling the content within cards, Bootstrap includes a few options for laying out series of cards.
Card groups
Use card groups to render cards as a single, attached element with equal width and height columns. Card groups start off stacked and use display: flex; to become attached with uniform dimensions starting at the sm breakpoint.
This layout uses container queries, so wrap the card group in a query container—add the .contains-inline utility to a parent element—for the row layout to take effect. Without a query container, the cards remain stacked.
<div class="card-group"> <div class="card"> <div class="card-body"> <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="fg-2">Last updated 3 mins ago</small></p> </div> </div> <div class="card"> <div class="card-body"> <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="fg-2">Last updated 3 mins ago</small></p> </div> </div> <div class="card"> <div class="card-body"> <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="fg-2">Last updated 3 mins ago</small></p> </div> </div> </div> </div>`} />
When using card groups with footers, their content will automatically line up.
<div class="card-group"> <div class="card"> <div class="card-body"> <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="fg-2">Last updated 3 mins ago</small> </div> </div> <div class="card"> <div class="card-body"> <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="fg-2">Last updated 3 mins ago</small> </div> </div> <div class="card"> <div class="card-body"> <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="fg-2">Last updated 3 mins ago</small> </div> </div> </div> </div>`} />
Grid cards
Use the Bootstrap grid system and its .row-cols classes 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 .md:row-cols-2 splitting four cards to equal width across multiple rows, from the medium breakpoint up.
<div class="col"> <div class="card"> <div class="card-body"> <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> </div> </div> </div> <div class="col"> <div class="card"> <div class="card-body"> <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> </div> </div> </div> <div class="col"> <div class="card"> <div class="card-body"> <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.</p> </div> </div> </div> <div class="col"> <div class="card"> <div class="card-body"> <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> </div> </div> </div> </div>`} />
Change it to .row-cols-3 and you’ll see the fourth card wrap.
<div class="col"> <div class="card"> <div class="card-body"> <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> </div> </div> </div> <div class="col"> <div class="card"> <div class="card-body"> <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> </div> </div> </div> <div class="col"> <div class="card"> <div class="card-body"> <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.</p> </div> </div> </div> <div class="col"> <div class="card"> <div class="card-body"> <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> </div> </div> </div> </div>`} />
When you need equal height, add .h-100 to the cards. If you want equal heights by default, you can set $card-height: 100% in Sass.
<div class="col"> <div class="card h-100"> <div class="card-body"> <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> </div> </div> </div> <div class="col"> <div class="card h-100"> <div class="card-body"> <h4 class="card-title">Card title</h4> <p class="card-text">This is a short card.</p> </div> </div> </div> <div class="col"> <div class="card h-100"> <div class="card-body"> <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.</p> </div> </div> </div> <div class="col"> <div class="card h-100"> <div class="card-body"> <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> </div> </div> </div> </div>`} />
Just like with card groups, card footers will automatically line up.
<div class="col"> <div class="card h-100"> <div class="card-body"> <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="fg-2">Last updated 3 mins ago</small> </div> </div> </div> <div class="col"> <div class="card h-100"> <div class="card-body"> <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="fg-2">Last updated 3 mins ago</small> </div> </div> </div> <div class="col"> <div class="card h-100"> <div class="card-body"> <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="fg-2">Last updated 3 mins ago</small> </div> </div> </div> </div>`} />
