SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot matches's Avatar
    Join Date
    Aug 2006
    Posts
    196
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    dynamically pick styles within the CSS file?

    Hello,

    I am working with a colleague in a different department right now. His department provides a bit of html in an iframe that contains a link to a style sheet. However, I wanted him to remove the link so that I could change the style sheet based on a users cookie. The differences are pretty drastic so I was thinking that it is best to use JS to pick between two separate CSS files. This other person mentioned something about making the CSS file "intelligent" and show the appropriate styles based on the cookie. Is there a way to determine what cookie a user has and have one style sheet display different styles? Not to my knowledge but I just wanted to through it out there.

    Thanks for your input

  2. #2
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,389
    Mentioned
    180 Post(s)
    Tagged
    6 Thread(s)
    Hi,

    Not sure if this is exactly what you were after but you could read a cookie then place a class in the body tag dynamically depending on the cookie value. Then you could set up different styles based on the class in the body tag etc.

    e.g.
    body.no-warning h1{color:green}
    body.warning h1 {color:red}

    Similar to this:

    http://www.alistapart.com/articles/bodyswitchers/

    However, its not really much different from switching the stylesheet as required except that its all in the same stylesheet.

  3. #3
    SitePoint Zealot matches's Avatar
    Join Date
    Aug 2006
    Posts
    196
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well, frankly I didn't know what I was looking for. I wasn't sure it was even possible.

    This solution you pointed out is an interesting and creative solution... I like!


Bookmarks

Posting Permissions

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