Forum Moderators: not2easy
With the css as below things work OK for what I want with #footblock. BUT not with #copyright - it only shows on print preview/print if I have display blank.
Obviously I'm doing something wrong, but I can't see what (and I didn't think inheritance applied here). Please can anyone help? Thanks, Jools
#ftr {
height: 10%;
margin-bottom: 2%;
width: 100%;
clear: both;
}
#copyright {
display: none;
}
#footblock {
float: right;
width: 75%;
}
In the @media print rule
div#ftr {
}
div#copyright {
}
div#footblock {
display: none;
}
<!-- start of ftr div -->
<div id="ftr">
<!-- start of copyright div--><div id="copyright"><table width="90%" border="0" cellpadding="0">
<tr>
<td height="71"><h1>blahblah</h1> </td>
</tr>
</table>
</div><!-- end of copyright div-->
<!-- start of footblock div -->
<div id="footblock"> <table width="90%" border="0" align="center" cellpadding="0" id="valid">
<tr>
<td height="83" align="center"><div align="center"><img src="../images/valid-html401.gif" alt="Valid HTML" width="88" height="31" align="top"></div></td>
<td class="update">blahblah</td>
<td align="right"><div align="center"><img src="../images/validcss.gif" alt="Valid CSS" width="88" height="31" align="top"></div></td>
</tr>
</table>
</div><!-- end of footblock div -->
</div><!-- end of ftr div -->
So, if your print style sheet comes first in the document, this is the order in which the rules will be loaded:
div#copyright {
}
div#footblock {
display: none;
}
#copyright {
display: none;
}
#footblock {
float: right;
width: 75%;
}
As you can see, the #footblock is successfully hidden from view, whereas the #copyright div is still going to be hidden. In fact, even if your print style sheet comes last, the result will be the same:
#copyright {
display: none;
}
#footblock {
float: right;
width: 75%;
}
div#copyright {
}
div#footblock {
display: none;
}
There's nothing in the second #copyright rule that will reset/change the display value.
I'll leave it at that for now, and see what you come up with ;)
I realise I'm about to be seriously thick with my next question (sorry) but am I correct in understanding that if the styles are in the order
div#copyright {
} These are in the @media print rule
div#footblock {
display: none;
}
#copyright {
display: none;
} These are in the ordinary page css
#footblock {
float: right;
width: 75%;
}
they will cause the page to be rendered differently to styles in the order
#copyright {
display: none;
}
#footblock {
float: right;
width: 75%;
}
div#copyright {
}
div#footblock {
display: none;
}
I had not realised (in my ignorance) that the order of styles (a: excepted) was relevant.
Am I on the right lines here or just happily going off at a tangent? ;)
Jools
Say that I have a style sheet with that looks exactly like this:
p {
color: red;
}
p {
color: blue;
}
Will my paragraphs be red or blue? Well, of course it's blue, since it comes last, and overrides the first rule.
What if I do this instead:
p {
color: red;
}
p {
}
Well, now they will be red, since the second rule is just empty, and doesn't in any way override the first one.
More examples:
p {
color: red;
font: 1.2em NiftyFont;
}
p {
color: blue;
}
Blue :)
p {
color: red;
}
p {
font: 1.2em NiftyFont;
}
Red :)
Back to your problem... What you have to make sure is that the @media print style either overrides the main style, or is applied instead of the main style.
Back to your problem... What you have to make sure is that the @media print style either overrides the main style, or is applied instead of the main style.
This is driving me potty - four hours later and I still can't get it to work. I understand the "what" but not the "how".
! important doesn't work. Setting up a media.print rule and a media.screen rule doesn't seem to do the trick. Right now I can't face setting up a stylesheet for print and one for screen. I know css is a steep learning curve, but right now it's got me beat. Please will you put me out of my misery and narrow the "how" down for me. Thanks, Jools
Sure enough when I got home I looked and found I had left a statement in the stylesheet which was overiding the screen rule - took it out and bingo, it works OK.
I then finally get onto the web and see your message. Many thanks for pointing me in the right direction - your help and advice is greatly appreciated. Jools