Treehouse: Grow your CSS skills. Land your dream job.

Detect Mac or PC to deliver stylesheet?

  • # June 28, 2011 at 9:44 pm

    On my PC the styles are working as I’d like them to, but when I test on a Mac things are a bit different, I am assuming it is related to the way a Mac renders text in the browser compared to a PC that is throwing off the widths. Is there a way to detect if a user is on a Mac or a PC and then deliver a corresponding stylesheet?

    # June 28, 2011 at 10:08 pm

    What exactly is the problem you are experiencing? I would imagine you shouldn’t need to detect OS.

    I suppose you could detect OS with Javascript, though I don’t have specific code for you.

    # June 28, 2011 at 10:47 pm

    I have a horizontal drop down menu and due to width differences in the way browsers render text and also the way text is rendered between PC and Mac browsers there was up to a 25px difference in widths which made positioning not work until I started using browser specific styles to adjust the width based on browser/OS. I searched all over Google and I have not been able to find a solution because it basically boils down to the fact that the font rendering makes the difference in widths, I suppose I could use images for the links instead but that’s not really what I want to do…

    # June 28, 2011 at 11:42 pm

    I went ahead and just used sprites after all, it works cross-browser and was easier than doing a bunch of browser specific styles.

    # June 29, 2011 at 12:41 pm

    I have a feeling that if you were using something flexible you might not run into any problems, but hard to say without seeing what you are working on.

    # June 29, 2011 at 2:29 pm

    Sounds to me you haven’t reset your stylesheet.

    # June 30, 2011 at 1:36 pm

    I use Eric Meyer’s reset on all of my projects, the width effect is purely related to the way browsers render text and the difference in font rendering between mac and PC that was throwing off the width, with sprite images it works perfectly and saves me the trouble of conditional styles.

    # June 30, 2011 at 2:13 pm

    Well it’s kind of odd, I’ve never had that problem.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.