CSS to specify full page width at printing?
I have an html page that is printed pretty well thanks to print specific styling 开发者_如何学Pythonexcept for one thing : it does not use the full width of the page. In other words, I would like the page to be scaled to fill the page.
Is it possible to obtain that result using css styles ?
actually you can, with the @page
css rule, although it can change a bit between browser implementation.
You can set this in your css:
@page {
size:210mm 297mm;
margin: 0;
}
This will set the size of the page as A4 with no margins
I know in IE you cannot control things such as the default page margins that are set via the print dialog. These are usually 2cm and can only be overriden by the actual user in the print dialog. Other than that setting the main containers (html, body, etc.) to be width:100% and margin and padding to be 0 is the only other thing that you can do. Remember though that the margin set in CSS for html/body are within the print area of the page as defined in the print settings for the user.
精彩评论