4

Is there a way to target only Chrome on Mac ONLY? I have used:

@media screen and (-webkit-min-device-pixel-ratio:0) {

    /* Webkit Styles here */

}

But that renders in both WIN and MAC.

I would be open to approaching from the other angle and target IE and FF for Mac only if that's my only option.

I'm also wanting to NOT use JavaScript if I can avoid it.

Any ideas?

Kara
  • 6,115
  • 16
  • 50
  • 57
WizzyBoom
  • 920
  • 1
  • 8
  • 18
  • You could use a [jp2](http://echoone.com/pictures/filejuicer/gold.jp2) image like a old-school [spacer gif](http://stackoverflow.com/questions/10732164/do-i-need-to-use-spacer-images-when-coding-html-emails) to prop up the layout in Safari on OSX, but nothing for Chrome. – Paul Sweatte Jul 07 '12 at 00:57

3 Answers3

4

You can't do this with CSS at all may be you have to use javascript for this.

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
sandeep
  • 91,313
  • 23
  • 137
  • 155
2

What problem are you specifically looking to address with Chrome on Mac? This seems like the kind of thing which will break as soon as Chrome on Mac updates to fix whatever issue you're having - and with the speed they put out updates, would be pretty soon. Perhaps you should edit your question in such a way that it asks about the original problem you're dealing with, not the workaround you're trying to attempt.

Tim
  • 14,447
  • 6
  • 40
  • 63
0

You could parse through PHP's $_SERVER['HTTP_USER_AGENT'] variable to detect the browser and OS, and echo browser/OS-specific styles based on your findings. This way, the appropriate styles are served even if the user lacks the JavaScript necessary for client-side browser sniffing.

(Of course, viewers spoofing their user agents may trick your system into serving the wrong CSS, but who cares? It's their user-experience, they should know what they're getting into.)

Aaron
  • 5,137
  • 1
  • 18
  • 20
  • This would require that you configure Apache to run .css files through php, as well. – Tim Feb 16 '12 at 18:19
  • How so? You could have browser-specific CSS files on your server, and in the PHP file generating HTML to serve to the viewer, if the PHP condition detecting a particular browser/OS config is met, echo a `` element whose `href` value is the path to that CSS file. – Aaron Feb 16 '12 at 18:45
  • Oh, sorry, I was still in the frame of mind of thinking directly within the stylesheet. The problem with doing the `echo ` is that you'd have to include the browser check everywhere you include the CSS file - which somewhat goes against the idea of using CSS. – Tim Feb 16 '12 at 20:15
  • True, personally, I'd put that functionality in a discrete .inc file and call it in my main template page. Of course, this is assuming that I have a main template page. This is also assuming that I'm using PHP in the first place... – Aaron Feb 16 '12 at 23:32
  • 2
    This is assuming I'm using a computer in the first place which assumes I am a person. What. – Tim Feb 16 '12 at 23:36