Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
461 views
in Technique[技术] by (71.8m points)

css - Print footer on every printed page from website, across all browsers (Chrome)

Dear all, I tried CSS Position: Fixed Property but it does work properly on Firefox and IE(hack for IE6), but it's not working at all for Chrome. I thought Chrome being the latest will support it very easily but still it isn't. I Tried out <thead>,<tfoot><tbody> again works in IE and Firefox, but problematic in Chrome. Please any one have an alternate solution to it.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It seems like Chrome[webkit] has different way of handling position:fixed in print stylesheets than the rest of the browsers.

So the current answer to this question is:
There is no adequate solution for this in Chrome.

Whereas FF and IE render it on Every page, Opera doesn't show it at all, and webkit browsers only show it on the first page.

small test file:

    <!DOCTYPE HTML>
    <html lang="en-US">
    <head>
    <meta charset="UTF-8">
    <title>print css test by mtness</title>
    <style type="text/css">
    @media print {
    #watermark { 
    display: block;
    position: fixed;
    top: 0;
    right: 0;
    z-index: 5;
    }
    
    p { 
    position: relative;
    top: 40pt;
    display: block;
    page-break-after: always;
    z-index: 0;
    }
    }
    </style>
    </head>
    <body>
    <div id="watermark">AWESOME!</div>
    <p>page1</p>
    <p>page2</p>
    <p>page3</p>
    </body>
    </html>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...