添加始终显示在屏幕底部的页脚?
即使页面内容非常小,我如何添加始终位于屏幕底部的页脚,
例如问题,假设我有一个页面,其中显示的内容不多,因此页脚变为屏幕中间。我能否确保如果页面内容不多,则页脚位于屏幕底部?
更新
当没有足够的内容来填充整个屏幕时,我只想要一个位于屏幕底部的页脚(即我不希望页脚显示在屏幕中间)然后如果有足够的内容,就可以将其放在页面底部。
How can i add a footer that is always at the bottom of the screen even when the page contents are very small
e.g of problem, lets say I have a page that doesn't have that much on display in it, the footer therefore becomes in the middle of the screen. Can I ensure that if the page doesn't have a lot of contents then the footer just be at the bottom of the screen?
UPDATE
I just want a footer that is at the bottom of the screen when there is not enough content to fill the whole screen (i.e I don't want the footer showing up in the middle of the screen) and then if there is enough content for it to just go down at the bottom of the page.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
页脚显示在页面底部>
使用内容类作为页面数据和页脚作为页脚
The footer is shown at the bottom of the page>
Use content class as page data and footer for footer
使用引导类
Use bootstrap class
您还可以使用粘性来定位位置,如下所示:
You can also use sticky for the position as shown below:
您需要使用绑定到页面底部的固定位置元素。
假设您使用 div 来包含页脚,您将需要一些像这样的 css:
当用户调整表单大小时,您可能需要更新高度和宽度。您可能还需要调整页面加载的宽度。
You'll want to use a fixed position element that is bound to the bottom of the page.
Say you use a div to encompass the footer, you'll want some css like this:
You'll probably want to update the height and width when a user resizes the form. You probably will need to resize the width on pageload as well.
使用以下 CSS 属性:
use the following css properties:
这是一个仅 CSS 的解决方案,不需要 jQuery。使包装器的最小高度为 100% 并相对定位,然后将页脚绝对定位到左下角:
来源
Here's a CSS only solution, no jQuery needed. Make the wrapper's minimum height 100% and position it relatively, then position footer absolutely to bottom left:
Source
您正在寻找“粘性页脚”,本文展示了您可以使用的一些技术:
这是 Flexbox 版本: http://codepen.io/chriscoyier/pen/RRbKrL
HTML:
CSS:
You're after a "sticky footer", this article shows some of the techniques you can use:
Here's the flexbox version: http://codepen.io/chriscoyier/pen/RRbKrL
HTML:
CSS: