简体   繁体   English

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

[英]Force browser to render webpage's Print stylesheet

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?我的问题是,是否可以强制浏览器使用打印样式表呈现页面而不实际打印它?

In Chrome (version 78), you can force the browser to render the webpage's print stylesheet using Chrome DevTools by going to More Tools > Rendering在 Chrome(版本 78)中,您可以通过转到“更多工具” >“渲染”来强制浏览器使用 Chrome DevTools 渲染网页的打印样式表

打开 Chrome DevTools 渲染设置

then selecting the Print option in the Emulate CSS Media dropdown然后在Emulate CSS Media下拉菜单中选择Print选项

在 Chrome DevTools 中模拟打印媒体复选框

usually the print css has a media type of print.通常,打印 css 具有媒体类型的打印。 simply remove the media definition and use it in replace of the main style sheet只需删除媒体定义并使用它来代替主样式表

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

change to改成

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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