News for hackers. Stuff that matters.
Re:Avoid browser-specific CSS hacks with CssUserAgent (cssua... by erikpukinskis on Sunday January 02, 2011 @07:48PM (#2061661)
Seems like a neat project. I wonder if it wouldn't be better to use feature-based classes instead of browser-based classes though.

In the example they have IE5&6 specific code:

    .ua-ie-5 .logo-area,
    .ua-ie-6 .logo-area
    {
    /* IE versions < 7.0 don't fully support transparent 24-bit PNGs */
      background-image: url(logo.gif);
    }
But wouldn't it be more sensible to have something like this:

    .no-png-support
    {
      background-image: url(logo.gif);
    }
That way you hit all relevant browsers... not just the ones whose quirks you know about?
Re:Avoid browser-specific CSS hacks with CssUserAgent (cssua... by morganpyne on Sunday January 02, 2011 @07:49PM (#2061663)
My first reaction to this is that it is using user-agent sniffing which is always considered a bad idea. Capabililty detection seems to be the way to go for this kind of thing.

Why would I ever want to use this instead of something like modernizr.js?

Re:Avoid browser-specific CSS hacks with CssUserAgent (cssua... by mckamey on Sunday January 02, 2011 @08:21PM (#2061707)
Fair enough but CssUserAgent is a far lighter solution than Modernizr. I find that 99.9% of my CSS is the same per browser so I just need a slight tweak here or there which CssUserAgent does without a lot of overhead. Modernizr is about 5x the size and spends time manipulating lots of DOM objects to test features which might not even be used.
Re:Avoid browser-specific CSS hacks with CssUserAgent (cssua... by chime on Sunday January 02, 2011 @10:55PM (#2062016)
Capability detection works well for some cases, not all. I was working on a web-app today and was trying to make a menu-bar using ul/li with small icon images and no matter what I did, every single browser (chrome/ff/ie/opera) rendered slightly differently. In one browser I had to add display:block and in another, position:relative. Putting position:relative for all browsers did not work. One browser needed line-height:14px while another needed 20px.

I didn't want to spend 3 hours finding the root cause or the most elegant solution to this annoying little problem. So I just did _line-height:20px and it lined up perfectly in IE. And I used jQuery.browser.opera and addClass(".fixopera") to make sure it worked in Opera. Detecting the box-model etc. could help if it was related to box-model issues. When text and images just don't line up, what should I use?

Re:Avoid browser-specific CSS hacks with CssUserAgent (cssua... by mckamey on Monday January 03, 2011 @01:13AM (#2062307)
Use CssUserAgent and be done with it.
Re:Avoid browser-specific CSS hacks with CssUserAgent (cssua... by 8ig8 on Sunday January 02, 2011 @09:02PM (#2061799)
In my experience, if you're using a lot of browser hacks then you're doing something wrong. With that said, IE continues to be the problem child, so most of the time a hack or two is required. In this case, I think Paul Irish's method helps tremendously without the overhead of JS...

http://paulirish.com/2008/conditional-stylesheets-vs-css-hac...

Re:Avoid browser-specific CSS hacks with CssUserAgent (cssua... by mckamey on Monday January 03, 2011 @01:14AM (#2062308)
That's a creative solution. Too bad it only works for IE.
Re:Avoid browser-specific CSS hacks with CssUserAgent (cssua... by Gertig on Sunday January 02, 2011 @06:39PM (#2061490)
This looks like a very cool project Stephen. I thought it would have been nice to show a side by side comparison of with and without CssUserAgent.
Re:Avoid browser-specific CSS hacks with CssUserAgent (cssua... by mckamey on Sunday January 02, 2011 @06:51PM (#2061525)
Interesting. As in a toggle to add/strip the classes back off again?