简体   繁体   English

浏览器控制的打印样式表文本

[英]Browser controlled text for print stylesheet

Is there an easy way to overwrite all text/header styles to let the browser handle the text formatting in the print stylesheet? 是否有一种简便的方法来覆盖所有文本/标题样式,以使浏览器处理打印样式表中的文本格式?

Edit: I have lots of styles such as 编辑:我有很多风格,例如

#id .class .class #id .class p{}

Make sure that any styles you have applied to the text / header which you do not want applied during "print" mode are specified as; 确保在“打印”模式下将不想应用于文本/标题的任何样式指定为;

@media screen {
  .headerStyle { color: green; }
}

They will then be ignored during the @print screen mode. 在@print屏幕模式下,它们将被忽略。

No. You can only cascade downwards, and you can't refer to other styles. 不可以。您只能向下层叠,不能引用其他样式。 Limit the CSS you have to the media types you want in the first place. 首先将CSS限制为所需的媒体类型

I have learnt that any CSS formatting created in a stylesheet specified as screen does means that the printing page will be unformatted. 我了解到,在指定为screen的样式表中创建的任何CSS格式的确意味着打印页面将未格式化。

In my example, I can't touch the HTML and the CSS media has not been specified, so the problem remains, but you should always make sure you set this to avoid problems in other medias. 在我的示例中,我无法触摸HTML并且未指定CSS媒体,因此问题仍然存在,但是您应始终确保进行设置以避免其他媒体出现问题。

Set the CSS globally (including print) 全局设置CSS(包括打印)

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

Set the CSS just for screen (excludes any media, including print format) 仅为屏幕设置CSS(不包括任何介质,包括打印格式)

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

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

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