[英]Javascript needed to fill remaining height space between content and footer
How can I set a "spacer" div to fill remaining height space between CONTENT and FOOTER, so footer will be always at the bottom of the page (not window as originally asked)? 如何设置“spacer”div来填充CONTENT和FOOTER之间的剩余高度空间,因此页脚将始终位于页面底部(不是最初要求的窗口)? Here is a example where footer is not at the window's bottom: http://template1.staceyapp.com/ (I'm using this template, so structure is the same). 这是一个示例,其中页脚不在窗口的底部: http : //template1.staceyapp.com/ (我正在使用此模板,因此结构是相同的)。 I've tried many things like creating a div and setting it to be min-height, height 100% etc. Probably Javascript is needed for that. 我尝试了很多东西,比如创建一个div并将其设置为min-height,height 100%等等。可能需要Javascript。 Are you able to help me setting jQuery to calculate it's height to fill the remaining space? 你能帮我设置jQuery来计算它的高度来填充剩余的空间吗? Is there a better solution? 有更好的解决方案吗?
Many thanks in advance, Graxa 非常感谢,Graxa
You can use CSS to position the footer at the bottom of the page. 您可以使用CSS将页脚定位在页面底部。
by using position: fixed
or if the footer is contained within another div (container) set the position
of that to relative
and the position
of your footer to absolute
and then specify bottom: 0;
通过使用position: fixed
或者如果页脚包含在另一个div(容器)中,则将该position
设置为relative
,将页脚的position
为absolute
,然后指定bottom: 0;
for your footer to keep it locked to the bottom of the page. 为您的页脚将其锁定在页面底部。
It sounds like you want a sticky footer, which sits at the bottom of the browser window or at the bottom of the content, whichever happens to be longer. 听起来你想要一个粘性页脚,它位于浏览器窗口的底部或内容的底部,无论哪个更长。
If that's true, check out: http://ryanfait.com/sticky-footer/ 如果这是真的,请查看: http : //ryanfait.com/sticky-footer/
您是否尝试将页脚设置为位置:固定在底部?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.