Noobie alert!
I have a document with an accompanying css that specifies the right-margin
of a particular div. It also has a @print section which overrides that
same right-margin setting. Works fine for screen and printer.
Now I've recently added some js that directly modifies marginRight on that
same div on certain events.
Trouble is, for printing the @print section of the css is now seemingly
ignored, and the margins used on the printout are those (last) modified
dynamically in the js. IOW, I would like to have the js modify the
_screen_ view only, *not* the print view.
Any way to do this? I've tried different .css for screen and print, but to
no avail.
I've wondered about setting the style dynamically before printing, but I
can't find any event that is triggered on print either...
Regards,
--
Mark McDougall, Engineer
Virtual Logic Pty Ltd, <http://www.vl.com.au>
21-25 King St, Rockdale, 2216
Ph: +612-9599-3255 Fax: +612-9599-3266
You are off in the weeds. This is what !important rules are for. In
other words, your print style sheet can override the inline style(s)
set by your script. Ask in a CSS group if you need more information.
> Hi gurus,
>
> Noobie alert! [...]
Here I stopped reading.
<http://www.catb.org/~esr/faqs/smart-questions.html#id382403>
Then I read David's followup and saw my assumptions confirmed.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Could you please point me to the place(s) in the CSS 2(.1) Specification
that say(s) `!important' declarations in a document stylesheet would have a
greater specificity than the `style' attribute of an element in a document?
Because I sure cannot find it.
Therefore, I propose the following two alternatives to applying inline
styles with the `style' attribute or property.
A) Add a stylesheet dynamically that uses ID or class selectors, with
`!important' where necessary.
B) (not as compatible) Add a `style' element dynamically that declares the
property values for the screen in a `@media screen' block, or a `link'
element referencing a prepared resource with media="screen" attribute,
with `!important' declarations where necessary.
> Ask in a CSS group if you need more information.
ACK, for the CSS part.
PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)
> Then I read David's followup and saw my assumptions confirmed.
And those assumptions would be... ???
That's as maybe. I don't have time to look for it, nor do I know for
sure if it is a normative standard.
>
> Therefore, I propose the following two alternatives to applying inline
> styles with the `style' attribute or property.
>
> A) Add a stylesheet dynamically that uses ID or class selectors, with
> `!important' where necessary.
Eh, you could. Would be faster if you are changing lots of styles at
once.
>
> B) (not as compatible) Add a `style' element dynamically that declares the
> property values for the screen in a `@media screen' block, or a `link'
> element referencing a prepared resource with media="screen" attribute,
> with `!important' declarations where necessary.
Don't use media="screen". It leaves out projectors, mobile, etc. Use
media="all" and then override with media="print".
>> A) Add a stylesheet dynamically that uses ID or class selectors, with
>> `!important' where necessary.
>
> Eh, you could. Would be faster if you are changing lots of styles at
> once.
Except it doesn't work. Same problem.
> Don't use media="screen". It leaves out projectors, mobile, etc. Use
> media="all" and then override with media="print".
FWIW this is for an in-house application that will only ever be used on a
"screen". However, I see your point.
I was wondering whether or not it was possible to write the js in such a
way as to affect only the "screen" margin, but it would seem not. So,
ultimately, this is a css problem - no?
> Except it doesn't work. Same problem.
Apologies, I stand corrected. I neglected to remove the media=print
sytlesheet from the head.
This does work! Thankyou!
I don't follow?
>
> This does work! Thankyou!
The !important trick? You bet. I've used it for ages in handheld and
print media style sheets (for just this purpose).
> Thomas 'PointedEars' Lahn wrote:
>> Then I read David's followup and saw my assumptions confirmed.
>
> And those assumptions would be... ???
(If you need to ask that question, you are in the target group because the
explanation was given in the very same posting.)
FWIW: The assumption that people who resort to groveling are usually doing
so in order to hide that they have not done their homework, thus are usually
not worth investing (my) time in.
> I don't follow?
Sorry. I had added a 2nd stylesheet with media="print", but was changing
the original stylesheet and not seeing the changes in the printed version.
After removing the "print" stylesheet and changing the media on the
original back to "all" it worked.
> FWIW: The assumption that people who resort to groveling are usually doing
> so in order to hide that they have not done their homework, thus are usually
> not worth investing (my) time in.
I was not "grovelling" (note spelling) as you are so fond of putting it
(no doubt because it strokes your ego to think some of us may be throwing
ourselves at your feet begging for enlightenment). I was merely alerting
readers/respondents that my question may either be trivial to answer or my
underlying premise may have been way off base.
(And FWIW, I'm really not that interested in anyone's opinion on How To
Ask Questions... so I'm not sure why you felt it necessary to post that?)
As for not doing my "homework"; you have of course absolutely no evidence
on which to base that accusation. For the record, I've been cutting my
teeth on HTML, CSS, Ruby, Rails and, most recently Javascript with the aid
of textbooks, online references and example code for months and this is
the first time I've resorting to posting a question on any subject.
And since you're also so fond of pushing netiquette, how about this one...
If you don't have anything _constructive_ to say, STFU.
Unfortunately, smug, presumptuous, rude & sad little men are all too
common in this profession... "I'm not worthy! I'm not worthy!"
Reminds me of someone... can't quite place who???
LOL!
If you are interested and still upset, google 'Asperger syndrome symptoms'.
> (And FWIW, I'm really not that interested in anyone's opinion on How To
> Ask Questions... so I'm not sure why you felt it necessary to post that?)
I think you do not understand usenet.
Posting should never be directed to the individual [only],
that's what email is for.
PE does not need to guess what you are interested in,
when he wants to post, as long as it is on topic.
Netiquette and the NG-FAQ are always on topic.
"How To Ask Questions" definitly is part of those.
Usenet is not a paid helpdask.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
> I think you do not understand usenet.
ROTFL!
> Usenet is not a paid helpdask.
NFI. No where did I demand any answers from anyone. All I presumed is that
I would be treated with some semblance of respect, not with dismissive
condescension.
Sigh. I guess if I've decided to mess with kiddie-script languages I can
only expect to have to deal with, kiddies... :(
> Evertjan. wrote:
>
>> Usenet is not a paid helpdask.
>
> NFI. No where did I demand any answers from anyone. All I presumed is
> that I would be treated with some semblance of respect, not with
> dismissive condescension.
And you find you were wrong in that presumption?
> Sigh. I guess if I've decided to mess with kiddie-script languages I
> can only expect to have to deal with, kiddies... :(
> Mark McDougall, Engineer
Indeed,
Engineers should not mess with such profane languages.