Maintaining the footer at the page's bottom is a common web design requirement. However, some users encounter difficulties using the "absolute" positioning property. This article will guide you through the correct CSS implementation to achieve a sticky footer effect without disrupting your layout.
Users attempting to fix their footer position unsuccessfully have typically applied the following code:
position: absolute; left: 0; bottom: 0; height: 100px; width: 100%;
To resolve the issue without using plugins or additional HTML elements, follow these steps:
html { position: relative; min-height: 100%; } body { margin: 0 0 100px; /* bottom = footer height */ } #bottom-footer { position: fixed; left: 0; bottom: 0; height: 100px; width: 100%; }
Note: It's recommended to use the HTML element ID "#bottom-footer" for targeting instead of "footer #bottom-footer," as the latter may conflict with your original CSS styling.
The above is the detailed content of How to Create a Sticky Footer in CSS Without Absolute Positioning?. For more information, please follow other related articles on the PHP Chinese website!