我正在尝试 鞋带,我想知道,如何才能修复页脚的底部,而不会让它从页面中消失,如果内容是滚动的?
To get a footer that sticks to the bottom of your viewport, give it a fixed position like this:
footer { position: fixed; height: 100px; bottom: 0; width: 100%; }
Bootstrap includes this CSS in the Navbar > Placement section with the class fixed-bottom. Just add this class to your footer element:
fixed-bottom
<footer class="fixed-bottom">
Bootstrap docs: https://getbootstrap.com/docs/4.4/utilities/position/#fixed-bottom
You might want to check that example: http://getbootstrap.com/2.3.2/examples/sticky-footer.html
Add this:
<div class="footer navbar-fixed-bottom">
https://stackoverflow.com/a/21604189
EDIT: class navbar-fixed-bottom has been changed to fixed-bottom as of Bootstrap v4-alpha.6.
navbar-fixed-bottom
http://v4-alpha.getbootstrap.com/components/navbar/#placement
Add z-index:-9999; to this method, or it will cover your top bar if you have 1.
z-index:-9999;
1
Add fixed-bottom:
<div class="footer fixed-bottom">
You can do this by wrapping the page contents in a div with the following id styling applied:
<style> #wrap { min-height: 100%; height: auto !important; height: 100%; margin: 0 auto -60px; } </style> <div id="wrap"> <!-- Your page content here... --> </div>
Worked for me.
Another solution :
You can use "min-height: 80vh;".
This allows you to set the minimum height, using the viewport height.
Example with bootstrap :
<style> main { min-height: 80vh; height: auto !important; height: 100%; margin: 0 auto -60px; } </style> <main class="container"> <!-- Your page content here... --> </main> <footer class="footer navbar-fixed-bottom"> <!-- Your page footer here... --> </footer>
More information : https://developer.mozilla.org/fr/docs/Web/CSS/length