Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Nov 2003
    Location
    San Francisco
    Posts
    45
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Question Conditional CSS Prob

    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:

    Code:
    <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

    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!

  • #2
    New Coder
    Join Date
    Nov 2003
    Location
    San Francisco
    Posts
    45
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Lightbulb Prob Solved!

    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •