Is there a CSS hack that targets only Chrome on Mac?

12,759

Solution 1

Unfortunately you can't do it without js. Some simple code from Chris Coyier:

if (navigator.userAgent.indexOf('Mac OS X') != -1) {
  $("body").addClass("mac");
} else {
  $("body").addClass("pc");
}

http://css-tricks.com/snippets/javascript/test-mac-pc-javascript/

Solution 2

I don't think you can do this with CSS, it looks like JavaScript might be your only option.

What problem are you actually having with Chrome on Mac? You might not need to target specific browsers/operating systems, post your problematic code and we might be able to give you some CSS that will work cross-browser and operating system.

Share:
12,759
Phish
Author by

Phish

Updated on June 05, 2022

Comments

  • Phish
    Phish almost 2 years

    I know that this is extremely unlikely to get the response I am looking for but I was looking for some sort of hack that would allow me to change the CSS on chrome JUST on MAC and not Windows.

    I am working on a large Java/JSP product and have very limited access to change the HTML so I HAVE to position a single element using a margin(s).

    I have used some CSS hacks to get the position pixel perfect on FF, IE 7,8,9, and 10, WIN Chrome, Opera and Safari however on MAC Chrome and MAC Safari it is a few pixels out.

    I am really hoping I don't need to use some JavaScript to check the user agent string and change the margin that way but needs must.

    Am I missing another CSS hack here?

  • Quentin
    Quentin over 10 years
    Android phones are PCs now?
  • Mihey Egoroff
    Mihey Egoroff over 10 years
    Oh, it can be .mac and .non-mac classes, anyway
  • Phish
    Phish over 10 years
    Gawd dammit, well I thought that it would be worth asking, I know these things can change. Thank you for the feedback