开发者

Printing html ignores CSS stylesheets

开发者 https://www.devze.com 2023-01-20 04:48 出处:网络
I have a very si开发者_如何转开发mple html page with a table element. The document is styled with css. When I print the page it looks like there are no stylesheets at all. Wrong font, everything is

I have a very si开发者_如何转开发mple html page with a table element.

The document is styled with css. When I print the page it looks like there are no stylesheets at all. Wrong font, everything is wrong.

What's the problem here? Do I have to create a special css only for printing? In my case it would be the same.. Is that really necessary?


Without the link to the page, I can only offer little advice.

  • Make sure the link to the stylesheet in the header is correct. And it should look something like this:

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

I just noticed that you mentioned print. The all media type will work across web and print. However, if you wanted to explicitly state another stylesheet for print than replace the all with print.

  • Check to see if the style are not being overridden by something else. As CSS is Cascading Style Sheets
  • Get Firebug.


If your stylesheet link has media="screen", then it will be ignored by print. In that case you can create a separate print stylesheet with media="print" or just change your existing style sheet to media="all".


The media attribute is used to determine the stylesheet purpose. You need to make sure that it is set to all (for all purposes) or print (only used when printing).

0

精彩评论

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

关注公众号