CSS, JavaScript and XHTML Explained

Estelle Weyl’s Blog of quirks, random thoughts and funky finds discovered in day-to-day coding

 

Hack for Webkit: Filter for Chrome and Safari April 21, 2010

Filed under: Browsers, CSS (including hacks) — Estelle Weyl @ 7:39 pm

To target only webkit, which includes Google and Safari, encompass all the CSS that you want to use just to target Webkit in the following @media block:

@media screen and (-webkit-min-device-pixel-ratio:0) {
     .myClass { background-color: #FF0000; }
     #myId {color: #0000FF;}
     p, a, li {text-shadow: 3px 3px 3px rgba(0, 0, 0, 0.4);}
}

Put the above code anywhere in your CSS file. The other browsers will read the rest, but only webkit reads the -webkit-min-device-pixel-ratio of the declaration, and therefore only Chrome and Safari will abide by the rules in the CSS code block.

The important stuff to learn:

@media screen and (-webkit-min-device-pixel-ratio:0) {
     /* put webkit CSS here*/
}


Share and Enjoy:
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Google
  • YahooMyWeb
 

4 Comments for this post

 
lanqy's blog Says:

[...] 代码来自Estelle Weyl [...]

 
Webdev Weekly #16 | samuli.hakoniemi.net Says:

[...] Hack for Webkit: Filter for Chrome and Safari [...]

 
stefan Says:

thanks for the hack

 
Andrew Says:

Thanks Estelle!

Leave a Reply