Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a Google Chrome-only CSS hack? [closed]

Is there a Google Chrome-only CSS hack? Many previously existing hacks that used to work for Chrome now are being picked up (used) by other browsers. I need one that targets Google Chrome, but not also other browsers like Mozilla Firefox, Safari, or Microsoft Edge.

like image 898
Sandy Avatar asked May 30 '12 07:05

Sandy


People also ask

Can CSS be hacked?

CSS hacks are sometimes used to achieve consistent layout appearance in multiple browsers that do not have compatible rendering. Most of these hacks do not work in modern versions of the browsers, and other techniques, such as feature support detection, have become more prevalent.

How do I apply a specific CSS rule to Chrome?

Use of the new @supports at-rule or 'feature check' allows your browser to check if a specific CSS property or feature, and its value, is supported in the user's browser.


2 Answers

Sure is:

@media screen and (-webkit-min-device-pixel-ratio:0) {      #element { properties:value; }  } 

And a little fiddle to see it in action - http://jsfiddle.net/Hey7J/

Must add tho... this is generally bad practice, you shouldn't really be at the point where you start to need individual browser hacks to make you CSS work. Try using reset style sheets at the start of your project, to help avoid this.

Also, these hacks may not be future proof.

like image 77
Alex Avatar answered Oct 02 '22 19:10

Alex


Only Chrome CSS hack:

@media all and (-webkit-min-device-pixel-ratio:0) and (min-resolution: .001dpcm) {     #selector {         background: red;     } } 
like image 25
Yonatan Ayalon Avatar answered Oct 02 '22 21:10

Yonatan Ayalon