Performance: Flex utilities
Flex utilities affect layout calculation and rendering speed by controlling how elements align and distribute space using CSS Flexbox.
<ul class="d-flex justify-content-between"> <li>Home</li> <li>About</li> <li>Contact</li> </ul>
<ul class="list-inline"> <li class="list-inline-item">Home</li> <li class="list-inline-item">About</li> <li class="list-inline-item">Contact</li> </ul>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Using inline-block for layout | Multiple nodes with inline styles | Multiple reflows on resize | Higher paint cost due to layout shifts | [X] Bad |
| Using Bootstrap flex utilities | Single flex container | Single reflow on resize | Lower paint cost with stable layout | [OK] Good |
d-flex do in a webpage layout?d-flexd-flex class in Bootstrap applies CSS flexbox display to the container, making its children flex items.d-flex = flex container row [OK]flex-column changes the flex direction from row (default) to column.d-flex class makes the container a flexbox, so combined with flex-column, items stack vertically.<div class="d-flex justify-content-center align-items-center" style="height: 100px;"> <div>Box</div> </div>
d-flex (flexbox), justify-content-center (horizontal center), and align-items-center (vertical center).<div class="d-flex flex-column justify-content-center"> <div>Item 1</div> <div>Item 2</div> </div>
justify-content-center centers items vertically along the main axis.align-items-center is needed but missing here.align-items-center to center items horizontally in column layout. -> Option Bflex-column for small screens (default) to stack vertically, and flex-lg-row for large screens to arrange horizontally.justify-content-between spaces items evenly across the container width on the main axis (horizontal in row).Pass the test and this pattern moves unknown