Grow your CSS skills. Land your dream job.

Jquery Browser Detection

  • # December 17, 2009 at 7:05 am

    I was having a problem with chrome. A div tag was positioned incorrectly so I looked for a Jquery script that could detect individual browsers, which you would then be able to give separate stylesheets.

    I found this
    http://www.tvidesign.co.uk/blog/CSS-Bro … hacks.aspx
    used it and it works more than perfectly.
    The script allows you to create css rules for basically any browser and I want to use this script, create 1 stylesheet called "browser.css" and then have a list such as:

    body.browserIE { background: #fff }
    body.browserIE ul.nav li a { margin: -20px 0 0 0}

    body.browserChrome { background: #000 }
    body.browserChrome ul.nav li a { margin: -70px 0 0 0}

    body.browserSafari { background: #ccc url(images/example.gif) repeat-x left top}
    etc.

    My question is: Is it better to do this, or is it better/safer to stick to the <!–[if condition]> HTML <![endif]–>? I haven’t heard about this before, but it could very well be because I am still a noob :lol: It would be very convenient to have all of the browsers’ css rules in one file.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".