Brasil

19 julho 2006 ~ 2 Comentários, deixe o seu »

CSS Browser Selector

Simple trick to help you on CSS hacks!

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

EXAMPLE

With this script you can set a different background color of one div for each browser.

  • Internet Explorer – yellow
  • Firefox – gray
  • Opera – green
  • Konqueror – blue
  • Safari – black

Source of this example:

<div class="example">

<style type="text/css">
.ie .example {
  background-color: yellow
}
.gecko .example {
  background-color: gray
}
.opera .example {
  background-color: green
}
.konqueror .example {
  background-color: blue
}
.safari .example {
  background-color: black
}
.example {
  width: 100px;
  height: 100px;
}
</style>

DOWNLOAD

css_browser_selector.js.txt (> 1KB)

Rename this file from .js.txt to .js before using

USAGE

1. Copy and paste the line above, inside <head> and </head> tag

<script src=”css_browser_selector.js” type=”text/javascript”></script>

2. Set the CSS attributes putting the code of the browser

Examples:

  • html.gecko div#header { margin: 1em; }
  • .opera #header { margin: 1.2em; }
  • .ie .mylink { font-weight: bold; }

Available Browser Codes:

  • ie – Internet Explorer
  • gecko – Mozilla, Firefox, Camino
  • opera – Opera
  • konqueror – Konqueror
  • safari – Safari

INSPIRATION

Original idea by 37 signals.

http://37signals.com/svn/archives2/browser_selectors_in_css.php

TO DO

  • Rails plugin

LICENSE

http://creativecommons.org/licenses/by/2.5/

AUTHOR

Rafael Lima (http://rafael.adm.br)

KEYWORDS

css javascript script cascading style sheet cross browser cross-browser browsers bug ie internet explorer konqueror safari opera firefox hack tip trick

2 Respostas para “CSS Browser Selector”

  1. Moises Kirsch 20 julho 2006 at 3:23 PM Permalink

    Hi,

    For some reason it is not working on Safari.

    This is a grat idea… I love that someone actually did it.

  2. Moises Kirsch 20 julho 2006 at 3:29 PM Permalink

    Hi,

    Me again…

    I found the problem.

    Theres a typo in the user agrent of Safari… it should be apple not aple.