Home >Web Front-end >CSS Tutorial >How to Stick a Footer to the Bottom of a Page with a Fixed Header?
In order to position a footer at the bottom of a page, while also having a fixed header, it is necessary to adopt an approach that does not rely on "position: fixed," which would place the footer relative to the viewport instead of the page itself.
Ryan Fait's approach is straightforward and effective for scenarios where both the header and footer are of fixed heights:
If the header should remain in its normal flow, simply add it within #content. To position it absolutely, you may use a spacer or the combination of padding-top and box-sizing.
Modern browsers support box-sizing: border-box. For wider browser support, consider using spacer elements instead.
The above is the detailed content of How to Stick a Footer to the Bottom of a Page with a Fixed Header?. For more information, please follow other related articles on the PHP Chinese website!