简体   繁体   English

将页脚Div放置在“最后一页”的底部(在屏幕上并打印)

[英]Position Footer Div at bottom of Last Page (on screen and print)

I have a requirement to position a div on the bottom of the last page when printing. 打印时,我需要在最后一页的底部放置一个div。 Consider I have a page set up as follows. 考虑我有一个页面设置如下。

[div id=Header]
[/div]

[div id=Lines]
     x Number of lines that could potentially span 1 or more pages
[/div]

[div id=Footer  style="position: absolute; bottom: 20px; left: 4px; right: 4px;"]
[/div]

No this code is fine if there are a few lines on the page, but if there are more than just a few the footer then overlaps some of the lines. 如果页面上有几行,则没有这段代码是好的,但是如果页脚多于几行,则某些行会重叠。 Is it possible in CSS to fix the footer to the bottom of the page, but to attach to the bottom of the second page if the lines fill the first page. 在CSS中是否可以将页脚固定在页面底部,但是如果这些行填充了第一页,则可以将其附加到第二页的底部。

I think its the position absolute that is causing the problem. 我认为是导致问题的绝对位置。 Has anyone else done this that has an alternative? 还有其他人这样做吗? I couldnt find another answer with a solution that worked for me 我找不到适合我的解决方案的其他答案

ps. ps。 sorry about the square brackets, couldnt work out how to get the markup in otherwise! 对方括号感到抱歉,否则无法解决如何获得加价的问题!

I think you want to obtain this result: http://jsfiddle.net/steweb/QAs78/ 我认为您想获得此结果: http : //jsfiddle.net/steweb/QAs78/

To let the footer stay at the bottom, you need to wrap your elements, and set the current wrapper style: 为了让页脚停留在底部,您需要包装元素,并设置当前包装器样式:

#wrapper{
    min-height:100%;
    position:relative;
}

Remember also to set 还记得设置

html,body{
    padding:0; /* to avoid y scrollbar */
    height:100%
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM