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.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3