Adding footer for printing web pages and setting margins

牧云@^-^@ 提交于 2019-12-11 05:15:54

问题


I want to add a footer to an HTML page that will be repeated across all pages WHEN PRINTING. I have managed to achieve this through this code:

@media print {
    p.note {
        bottom: 0; position: fixed; 
    }
}

But now I have a problem with this paragraph going on top of the rest of the copy

According this Mirosoft article, this should work for me:

@page :first {
    margin-bottom: 4in;
}

But it doesn't, it doesn't change anything... any ideas?


回答1:


Here's the solution that worked, CSS is this:

@media print {
    p.note {
        display:block;
        bottom:0;
        position:fixed;
        font-size:11px;
    }
}

And everything needs to be contained in a separate div with this CSS

#wrapper {
    position:relative;
    bottom:1in;
    margin-top:1in;
    width:974px;
    margin:0 auto;
}

This worked perfectly!




回答2:


How about adding some z-index ? It seems that the footer overrides the last paragraph Also try to use

@media print {
    p.note {
        bottom: 0; position: fixed;
margin-top:10px; 
    }
}



回答3:


Make sure that the container for the main content makes room for the footer. For instance, if your markup looks something like this:

<div id="content"><p>Lorem Ipsum Latin et cetera</p></div>
<p class="note">Footer</p>

You'd want some css like this:

#content {margin-bottom:4in}


来源:https://stackoverflow.com/questions/7439359/adding-footer-for-printing-web-pages-and-setting-margins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!