...

View Full Version : print css - is this specific requirement possible?



bazz
02-05-2005, 06:20 PM
OK I have a css for printing the web page. I want to use an attribute at the beginning to make all elements - display:none; including those called from the normal stylesheet.


Then I can list those in the print stylesheet that I need to display for printing.

bazz

Graft-Creative
02-05-2005, 07:00 PM
this could work:


* { display: none;
}


Sets everything not to display.

Then like you say, go through and select the things you want to display.

Gary

bazz
02-05-2005, 07:39 PM
yeh it works..... too well :) It stops everything displaying, including the code that flows below that line.

Bazz

rmedek
02-05-2005, 11:32 PM
lol, you get what you ask for... :D

I think it does that because the browser figures, "hey, if I don't need anything I'm not going through the trouble of loading anything..." What about "visibility: hidden"?

I've always wondered about this to tackle some of my more complicated IE stylesheets...

Graft-Creative
02-05-2005, 11:55 PM
yeh it works..... too well :) It stops everything displaying, including the code that flows below that line.

Bazz

:D could be a good ploy if you ever feel the need to stop folks printing your page, but that's besides the point
:rolleyes:

bazz
02-06-2005, 06:43 PM
:confused:

MAybe I didnt ask the right question?

OK this is the scenario....I am making the components of web pages with perl and they will be inserted into several pages on different websites. What I have found is that when I view print preview, the styles that are included in one stylesheet (for normal browser viewing), and which are not mentioned in the 'printcss.css (to become display none), become displayed anyway in the printable version. I want to ensure that all style stuff is excluded, except for that which is mentioned in the printcss.css stylsheet.

Whilst I have media="print" stated for the print-specific stylesheet, I have no control over other web-designers, who don't use the display="screen" attributes. I imagine that that would be the best way to achieve what I want but that would take too much toime as the 'designers' around here, all seem to use premade editing software and refuse to think that tables are bad, that doctypes are needed - I think you get the drift...

So, back on track, does anyone know of a solution for my little dilemma?


Bazz

Graft-Creative
02-06-2005, 11:29 PM
Are you sure the serverside includes don't contain the stylesheet link - I've seen this happen with dreamweaver freaks - all their includes contain the full doctype declaration, stylesheet link etc etc - because as they see it when making a file to be included they are just making a new html page - so its menu>new>html page - resulting in the head info being repeated several times throughout a page. Could that be the problem?

Gary

rmedek
02-06-2005, 11:55 PM
... and be sure to check if your main css has the "media="screen"" attribute, not "media="all"." I don't know if it makes a difference, but on the site I'm building now, the exact opposite of what you want is happening: My printed pages don't assume any of my main styles, so until I build a separate stylesheet for print, anything printed will be sans style.

bazz
02-07-2005, 02:19 PM
Please see my previous post.

I am providing perl outputted content for inclusion in pages made by other 'web-designers'. I have no control over how they code their page as they argue that tables are the way to do it and that css and doctypes arent necessary. Cripes some even say that there is simply no point in building the page for all those 'wee browsers' coz so few people use them!!!!

In a nutchell, they haven't even grasped the ability to put media="whatever" in their html. So I need to be able to override it with my print.css and I thought Graft-Creatives idea was good until I applied it and found it worked too well. It prevents from displaying, all the elements including those listed after the display none portion.

I have a solution which doesn't work, for whenever I know the classes etc for the others' websites - I simply put those into my print css and tell them to display none - individually. That is as I say, verbose but most often I don't know the specific tags they use and its too time consuming for me to check the antics of each site builder.

Ho Hum... we have a problem.

Bazz
[edit]
PS just another thought...this is an example of why standards are sooo important. code the page wrongly and even in the most used browser, the thing can't work!! I need a lie down - and its only Monday :eek:

rmedek
02-08-2005, 12:15 AM
Man I am confused now...

:confused: See?

If you only have control over portions of the total web page (the parts you are including via Perl), then it doesn't matter what trickery you add into the CSS-- chances are there will be something that you won't have control over that will display on a printed page. And how is your print CSS accessed anyway if you don't have control over what's in the <head>?

The only real solution I can see (other than having Perl rewrite the entire document file) is to make sure that your section of html is marked up as specific as possible, and that the web "developers" add these two lines to every page, in the head section:


<link rel="stylesheet" media="screen, projection" href="/css/style.css" />
<link rel="stylesheet" media="print" href="/css/print.css" />


Explain to them it's all you ask of life. :D

Graft-Creative
02-08-2005, 12:41 AM
Tricky one. To be honest it sounds like you're p*ssing in the wind with this, not your fault obviously. I just can't think of a way you can overide what your designers have done?

I tried:
* {display: none;
}

In Opera, with a xhtml 1.1 site I have, and was presented with a nice clean times new roman style page.

Maybe you could use a style switcher, with a print button on the page - using the above method to switch all styles off for the printed version?

It's not pretty, don't know if it works in IE. If the designers aren't using css for their designs, it's hard to see how you could implement css print styles anyway.

Gary

rmedek
02-08-2005, 01:04 AM
Hey, I just realized you could go old school with this one:

<a href="printversion.htm">Print version</a>

Ugly, but it used to be done that way...

Graft-Creative
02-08-2005, 01:21 AM
good call Richard, but I can't see Bazz's (cough) ultra co-operative (splutter) designers making two versions of the same page.

Bazz I'm really starting to think this is not your problem mate, of course, you want to do things right, but in the environment you're in I suppose sometimes you have to let things go. I just can't understand why the onus should be on you for what is basically a design issue? if your designers aren't savvy enough to make a print friendly version of thier designs then maybe they should be explaining why not to your boss?

Gary

bazz
02-08-2005, 03:49 PM
Thanks all.

I suppose Gary, it just isn't that simple. The designers work for themselves I work for myself and the cllients work for themselves. I am trying to bring better services to the client but the poor design of their sites, makes this even more difficult.

was much too long
Bazz



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum