...

View Full Version : Conditional CSS Prob



ccemmett
03-21-2004, 12:42 AM
I got to thinking that it ought to be possible to use javascript to write a CSS link into the head of a page dependent on user screen resolution thus making it possible to control page formatting through use of CSS and alternative graphics sets while eliminating the chore of maintaining duplicate pages for different resolutions.

Pasted the following into the head of the page:



<script type="text/javascript">
<!--
var sheet=""
if (screen.width<1024||screen.height<768)
sheet="css/lowres.css"
else{
sheet="css/hires.css"
}
document.write('<link rel="StyleSheet" href="'+sheet+'"type="text/css" media="screen"/>')

// -->
</script>


Works fine in IE6, but strange spacing problems occur in Mozilla. Page is here (http://www.goldengateaudubon.org/Conservation/fawr/newsite/)

You'll notice in Mozilla that the navigation division ends up getting shoved below the bottom of the window. I've tried accessing the style property of the division top margin to reset it but trying to do so returns "".

Any ideas? (Is it possible to access CSS loaded in cache?)

Thanks!

ccemmett
03-21-2004, 11:48 PM
A solution that worked was to simply set position: absolute for all the division containers on the page.

This works fine although I'm still curious about the fact that display: none doesn't work properly with Mozilla in this situation.

Really feel there must be a better and more flexible solution.

Hmmm.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum