开发者

Having printed matter use an exclusive stylesheet

开发者 https://www.devze.com 2023-02-23 18:55 出处:网络
Currently I have my stylesheets as such: <link rel=\"stylesheet\" media=\"print\" href=\"css/print.css\" type=\"text/css\" />

Currently I have my stylesheets as such:

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

Is there a way to force style.css to be only on a monit开发者_运维技巧or, and force print to only be on printed matter? I'm trying to make a printer-friendly page and it's taking forever to override the mass of rules in style.css.


Use media="screen" on the main stylesheet so styles are only applied on a monitor screen:

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

If you don't specify a media attribute, the stylesheet takes a default of media="all", which means styles are applied everywhere.

Read more about media types here (HTML spec) and here (CSS spec).

0

精彩评论

暂无评论...
验证码 换一张
取 消