Már maga az elképzelés nagyon jó, a css osztályokat tudjuk böngészőkre és operációs rendszerekre "szabni". Íme egy rövid példa:
<style type="text/css">
.ie .example {
background-color: yellow
}
.ie7 .example {
background-color: orange
}
.gecko .example {
background-color: gray
}
</style>
Nagyon könnyen lehet kiválasztani, hogy melyik osztály melyik böngészőben milyen tulajdonságokkal bírjon. A kód jelenleg a következő böngésző motorokat kezeli:
- ie - Internet Explorer (minden verzió)
- ie8 - Internet Explorer 8.x
- ie7 - Internet Explorer 7.x
- ie6 - Internet Explorer 6.x
- ie5 - Internet Explorer 5.x
- gecko - Mozilla, Firefox (minden verzió), Camino
- ff2 - Firefox 2
- ff3 - Firefox 3
- ff3_5 - Firefox 3.5
- ff3_6 - Firefox 3.6
- opera - Opera (minden verzió)
- opera8 - Opera 8.x
- opera9 - Opera 9.x
- opera10 - Opera 10.x
- konqueror - Konqueror
- webkit or safari - Safari, NetNewsWire, OmniWeb, Shiira, Google Chrome
- safari3 - Safari 3.x
- chrome - Google Chrome
- iron - SRWare Iron
Valamint az alábbi operációsrendszereket ismeri:
- win - Microsoft Windows (minden verzió)
- vista - Microsoft Windows Vista
- linux - Linux (x11 és linux)
- mac - Mac OS
- freebsd - FreeBSD
- ipod - iPod Touch
- iphone - iPhone
- ipad - iPad
- webtv - WebTV
- j2me - J2ME Devices (pl.: Opera mini)
- blackberry - BlackBerry
- android - Google Android
- mobile - All mobile devices
További példák:
- html.gecko div#header { margin: 1em; }
- .opera #header { margin: 1.2em; }
- .ie .mylink { font-weight: bold; }
- .mac.ie .mylink { font-weight: bold; }
általános példa: .[os].[browser] .mylink { font-weight: bold; } -> ne legyen szóköz az .[os] és .[browser] között
A készítő honlapja: http://rafael.adm.br/css_browser_selector/
A kód letölthető innen: http://github.com/rafaelp/css_browser_selector/raw/master/css_browser_selector.js