Performance: Why layout patterns solve common needs
This affects how quickly the page content appears and how smoothly it responds to user actions by optimizing layout calculations and rendering.
<div class="row"><div class="col-4">Item 1</div><div class="col-4">Item 2</div><div class="col-4">Item 3</div></div>
<div style="float:left; width:33.33%;">Item 1</div><div style="float:left; width:33.33%;">Item 2</div><div style="float:left; width:33.33%;">Item 3</div>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Float-based layout | Multiple DOM nodes with float styles | Multiple reflows per floated element | Higher paint cost due to layout thrashing | [X] Bad |
| Bootstrap Flexbox grid | Same DOM nodes with flex container | Single reflow for container | Lower paint cost with efficient compositing | [OK] Good |
.container and .container-fluid for grid containers..container-fluid creates a full-width responsive container..container-fluid -> Option A<div class='container'>
<div class='row'>
<div class='col-6'>Left</div>
<div class='col-6'>Right</div>
</div>
</div>.row creates a horizontal group, and .col-6 means half width columns..col-6 inside a .row appear side by side, each half width.<div class='container'>
<div class='row'>
<div class='col-8'>Main</div>
<div class='col-5'>Sidebar</div>
</div>
</div>col-12 makes columns full width on small screens (stacked), col-md-4 makes them one-third width on medium+ screens.col-md-4 divides row into three equal parts on desktop.col-12 col-md-4 for each column -> Option CPass the test and this pattern moves unknown