Performance: Card groups and decks
This concept affects page load speed and rendering performance by how multiple card components are grouped and laid out, impacting layout calculations and paint times.
<div class="row row-cols-1 row-cols-md-3 g-4"> <div class="col"> <div class="card h-100">...</div> </div> <div class="col"> <div class="card h-100">...</div> </div> <div class="col"> <div class="card h-100">...</div> </div> </div>
<div class="card-group"> <div class="card">...</div> <div class="card">...</div> <div class="card">...</div> </div>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Bootstrap card-group with variable content | Moderate DOM nodes | Multiple reflows due to height adjustments | Medium paint cost | [X] Bad |
| Bootstrap grid with h-100 cards | Moderate DOM nodes | Single reflow with fixed heights | Low paint cost | [OK] Good |
| Bootstrap card-deck (deprecated) | Moderate DOM nodes | Reflows on resize causing CLS | Medium paint cost | [X] Bad |
| Flex utilities with gap and flex-fill | Moderate DOM nodes | Minimal reflows, stable layout | Low paint cost | [OK] Good |
.card-group in Bootstrap?.card-group behavior.card-group class groups cards so they share the same height and appear connected without gaps..card-deck spaces cards evenly with margins, not connecting them tightly..card-group = same height + connected cards [OK]card-deck, which spaces cards evenly.card-group is for connected cards, and the other classes are not valid Bootstrap classes.card-deck [OK].card-group versus .card-deck for three cards side by side?.card-group layout.card-group makes cards the same height and connects them visually without gaps..card-deck layout.card-deck spaces cards evenly with margins, creating gaps between cards..card-group have equal height and no gaps; .card-deck cards have gaps and equal spacing -> Option B<div class='card-group'> <div class='card'>Card 1</div> <div class='card'>Card 2</div> <div class='card'>Card 3</div> </div>
card-group, which connects cards without spacing.card-deck should be used instead.card-deck instead of card-group for even spacing -> Option Acard-deck not card-group [OK].card-deck spaces cards evenly with margin and keeps them balanced in height..card-group connects cards without margin; .card-columns creates masonry layout, not equal height rows..card-deck to space cards evenly with margin and equal height -> Option Acard-deck [OK]Pass the test and this pattern moves unknown