Performance: Sidebar with content area
This affects the page's initial load speed and rendering performance by how the sidebar and content area are structured and styled.
<div class="d-flex"><nav class="flex-shrink-0 p-3 bg-light" style="width: 250px;">Sidebar</nav><main class="flex-grow-1 p-3">Content</main></div>
<div style="width: 250px; float: left;">Sidebar</div><div style="margin-left: 250px;">Content</div>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Float sidebar with margin content | Low | Multiple on resize and content change | Medium | [X] Bad |
| Bootstrap flexbox sidebar and content | Low | Single on resize | Low | [OK] Good |
d-flex to enable flexbox layout on a container.flex-row for horizontal layout.<div class='d-flex'> <nav class='bg-light p-3' style='width: 200px;'>Sidebar</nav> <main class='flex-grow-1 p-3'>Content area</main> </div>
d-flex class creates a flex container with default row direction, placing children side by side.nav has fixed width 200px, and main uses flex-grow-1 to fill remaining space.<div class='d-flex flex-column'> <nav class='sidebar'>Menu</nav> <main class='content flex-grow-1'>Main content</main> </div>
flex-column, which stacks children vertically.d-flex flex-row places sidebar and content side by side on larger screens.offcanvas component provides a sidebar that can toggle visibility on small screens.Pass the test and this pattern moves unknown