tags:

views:

63

answers:

2

The title sums it up. I'll get this out of the way and say I am aware that css hacks are dirty ugly horrible things. Sometimes dirty problems call for dirty solutions though :)

So does anyone know of a css selector hack that works for recent safari versions but is not a general webkit hack ? My site behaves properly in chrome but has a bug in safari. So if anyone knows how i can select an element to only have a certain style in safari let me know!

+1  A: 

What I'd do, is sniff the user agent of the browser with javascript, and add a class to the <body> element, based on that. That way you don't have to rely on any kind of hack, you just write your selectors based on the class:

.safari .misbehaving-div {
}

I believe there is already a JS framework that does exactly this, but I don't remember the name.

WishCow
If i already have jQuery loaded for other purposes on the page. Would a jQuery solution be best ?
JQuery will report webkit for both Chrome and Safari, since they are both webkit based. You have to look at the userAgent the "normal" way, but you can use jQuery for adding the class to the body.
WishCow
+2  A: 

Ended up using this:

http://rafael.adm.br/css_browser_selector/