开发者

Using print.css with @media print elsewhere

I've got a webpage that uses a site global print.css stylesheet to render the page for print. The page also uses sitewide classes for divs, headers, etc.

I need to increase the width of the body and the size of the font of this page in the print version. I don't have access to edit the global print.css, and would prefer not to make my changes there because the changes will affect 开发者_StackOverflow中文版other pages that I don't want to change (due to the use of global styles, div classes, etc.).

Fortunately, this page does have its own stylesheet, foo.css that I can edit to make changes that will only affect this page.

Further complicating this is that the page has an inline style on the body class that I need to change for print only.

Normally I would edit foo.css with my style change, using !important to override the inline style as needed, but what I can't figure out is:

  • Can I use @media print { body {width: 900px; !important;}} in foo.css and have it work even though I already have a print.css?

I've been trying to test this in Firebug (with Web Developer Toolbar), but if I add the @media print call to foo.css, nothing seems to happen.

Thoughts?


This should be possible. Things to check:

  1. is foo.css included with all media?

  2. You shouldn't have a ; before !important.

  3. Does your @media selector have higher specificity than the inline style?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜