简体   繁体   中英

Persisting the scroll position of DIV while printing

I would like to print scrollable div as WYSWYG. Is there a way?

Try adding the below to the @media-print to persist scrolling during print. This worked for me:

.className{
    overflow: scroll;
}

Not with pure css, I don't think. My...interpretation of what happens when you hit the print button is that the document's reloaded with either the media="print" or other relevant stylesheet, and then sent to print-preview/the printer as a new document, with all content in the default/start position as defined in that stylesheet.

Since I can't think of a way to position the scrolling content, using css, I'd have to say that it's not possible. Javascript's almost certainly the way to go on this one.

...may I ask why you'd want to do this? It's not a criticism, I just...don't understand.

I don't think you can do it even with javascript. It is against the spirit of the web. Printed document is supposed to look different.

I suspect that when you see a scroll bars on printed page, it is a bug to be fixed in future version of a browser.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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