Performance: Sticky footer pattern
This pattern affects the page's layout stability and loading speed by controlling footer positioning without causing layout shifts.
html, body { height: 100%; margin: 0; display: flex; flex-direction: column; } main { flex: 1 0 auto; } footer { flex-shrink: 0; }html, body { height: 100%; margin: 0; } .footer { position: fixed; bottom: 0; width: 100%; }| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Fixed position footer | Low | Multiple on scroll and load | High due to repaint and composite | [X] Bad |
| Flexbox sticky footer | Low | Single on load | Low | [OK] Good |
d-flex flex-column makes the body a vertical flex container, and min-vh-100 ensures full viewport height.<body class="d-flex flex-column min-vh-100"> <main class="flex-fill">Content</main> <footer class="bg-light text-center py-3">Footer</footer> </body>
flex-fill to fill available space.<body class="d-flex flex-column"> <main class="flex-fill">Content</main> <footer>Footer</footer> </body>
min-vh-100, the body height is only as tall as content, so footer won't stick at bottom.min-vh-100 class on the body -> Option C<body class="d-flex flex-column min-vh-100"> <main class="flex-fill">Content</main> <footer class="py-3 text-center">Footer</footer> </body>
bg-light for short pages and bg-dark text-white for tall pages using media queries uses Bootstrap background classes with media queries to switch colors depending on viewport or content height, which is correct.bg-light always and use JavaScript to toggle classes on scroll uses JavaScript unnecessarily; C breaks sticky footer by fixing position; D only adds static background color.bg-light for short pages and bg-dark text-white for tall pages using media queries -> Option APass the test and this pattern moves unknown