Performance: Gutters and spacing control
Controls spacing between grid columns and elements, impacting layout calculation and paint performance.
<div class="row g-3"> <div class="col">Content 1</div> <div class="col">Content 2</div> </div>
<div class="row"> <div class="col" style="margin-right: 20px;">Content 1</div> <div class="col">Content 2</div> </div>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Inline styles for spacing | No extra DOM nodes | Multiple reflows on resize | Higher paint cost due to layout thrashing | [X] Bad |
| Bootstrap gutter classes (e.g., g-3) | No extra DOM nodes | Single reflow on resize | Lower paint cost with stable layout | [OK] Good |
| Mixing inline styles and Bootstrap spacing | No extra DOM nodes | Extra reflows and style recalculations | Blocks rendering briefly | [!] OK |
| Using only Bootstrap spacing utilities (e.g., p-4) | No extra DOM nodes | Minimal reflows | Efficient paint with cached styles | [OK] Good |
g-3 do in a grid layout?g-3 sets the gutter size between columns to a medium spacing level.gx-0 removes horizontal gutters (x-axis), gy-0 removes vertical gutters (y-axis), and g-0 removes both.gx-0 is correct.<div class='row gx-4'> <div class='col'>A</div> <div class='col'>B</div> </div>
gx-4 on the columns?gx-4 sets horizontal gutters (x-axis) to size 4, which is large spacing.gy-0 removes vertical gutters, gx-3 sets horizontal gutters to size 3.g-2 on the row adds equal gutters (spacing) between all columns.p-3 on each column adds equal padding inside each column for internal spacing.g-2 on the row and p-3 on each column -> Option DPass the test and this pattern moves unknown