The Lodge is members-only design/dev videos and Office Hours.

Next Office Hours Session: "Implementing an SVG Icon System" Nov 30 - 6:00 PM Eastern

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 … 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}

    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.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed