强制浏览器呈现网页的打印样式表

时间:2022-11-19 12:02:01

A lot of web pages use a Print stylesheet to format things better for printing. My question is, is it possible to force the browser to render a page using the print stylesheet without actually printing it?

许多web页面都使用打印样式表来更好地格式化要打印的内容。我的问题是,是否可能强迫浏览器使用打印样式表来呈现页面,而不实际打印它?

2 个解决方案

#1


2  

usually the print css has a media type of print. simply remove the media definition and use it in replace of the main style sheet

通常,打印css有一种媒体类型的打印。只需删除媒体定义并使用它替换主样式表

<link rel="stylesheet" type="text/css" media="print" href="print.css" />

change to

改变

<link rel="stylesheet" type="text/css" media="all" href="print.css" />

#2


11  

In Chrome (version 48), you can force the browser to render the webpage's print stylesheet using Chrome DevTools by going to More Tools > Render settings

在Chrome(第48版)中,通过使用更多工具>呈现设置,您可以强制浏览器使用Chrome DevTools呈现网页的打印样式表

强制浏览器呈现网页的打印样式表

then checking the Emulate print media checkbox

然后检查模拟打印媒体复选框

强制浏览器呈现网页的打印样式表

#1


2  

usually the print css has a media type of print. simply remove the media definition and use it in replace of the main style sheet

通常,打印css有一种媒体类型的打印。只需删除媒体定义并使用它替换主样式表

<link rel="stylesheet" type="text/css" media="print" href="print.css" />

change to

改变

<link rel="stylesheet" type="text/css" media="all" href="print.css" />

#2


11  

In Chrome (version 48), you can force the browser to render the webpage's print stylesheet using Chrome DevTools by going to More Tools > Render settings

在Chrome(第48版)中,通过使用更多工具>呈现设置,您可以强制浏览器使用Chrome DevTools呈现网页的打印样式表

强制浏览器呈现网页的打印样式表

then checking the Emulate print media checkbox

然后检查模拟打印媒体复选框

强制浏览器呈现网页的打印样式表