Performance: Auto-sizing columns
This affects page load speed and rendering performance by controlling how column widths are calculated and laid out in the browser.
<div class="row"> <div class="col">Flexible column with max-width set via CSS</div> <div class="col">Another flexible column</div> </div>
<div class="row"> <div class="col-auto">Long content that changes size</div> <div class="col-auto">Another auto column</div> </div>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Multiple col-auto columns | Moderate (depends on number of columns) | Multiple reflows per column | Medium | [X] Bad |
| Fixed or flexible columns with max-width | Low | Single reflow | Low | [OK] Good |
col-auto do in a grid layout?col-auto purposecol-auto class sizes the column based on its content width, not stretching it.col which fills available space, col-auto fits tightly around content.col-auto = auto width fitting content [OK]col-auto fits content width exactly [OK]col-auto fills full container widthcol-auto with fixed pixel widthcol-auto exactly to auto-size columns.<div class='col-auto'>Content</div> uses the correct class col-auto with proper syntax.col-auto [OK]col-auto for auto-sizing columns [OK]auto-col-sizecolumn-auto<div class='row'> <div class='col-auto'>Logo</div> <div class='col'>Main content</div> </div>
col-auto effect on 'Logo'col-auto, so it sizes exactly to the width of 'Logo' text.col effect on 'Main content'col, which fills all remaining horizontal space.col-auto fits content, col fills leftover [OK]col-auto fits content; col fills rest [OK]col-auto fills full rowcol shrinks to content<div class='row'> <div class='col'>Menu</div> <div class='col-auto'>Search</div> </div>
col-auto, so it will auto-size to content width as expected.row class, which is correct for Bootstrap grid layout.col-auto class is correct; no mistake in code. -> Option Ccol-auto and row [OK]col-auto is on correct column and row exists [OK]col-auto must be on first columnrow class on containerd-flex for grid columnscol-auto to fit their content width.col to fill leftover horizontal space.<div class='row'>
<div class='col-auto'>Left</div>
<div class='col'>Center</div>
<div class='col-auto'>Right</div>
</div> matches this exactly: first and third columns use col-auto, middle uses col.<div class='row'>
<div class='col-auto'>Left</div>
<div class='col'>Center</div>
<div class='col-auto'>Right</div>
</div> [OK]col-auto for sides, col for center [OK]col-auto on center columncol on side columnscol-auto causing no flexible spacePass the test and this pattern moves unknown