-4

I'm trying to get a style in my code to change depending on whether Windows or Mac is being used. For Mac the code is:

<div class="special container container_6" style="position:relative; top:-123px">

and for Windows the code is:

<div class="special container container_6" style="position:relative; top:-127px"> 

This seems similar to what I want to do but it doesn't have an answer...

Any thoughts?

Community
  • 1
  • 1
  • 2
    What OS would you consider a ipad or android phone? – Jason Sperske Oct 18 '13 at 04:07
  • 2
    Why do you want to do this? Moving `4px` seems as if you want so solve a css problem that looks like a platform problem, but not necessarily needs to be one. – t.niese Oct 18 '13 at 04:07
  • 2
    What are you trying to accomplish? Generally, desktop OS detection isn't as good of an approach as coding CSS properly in the first place. – DACrosby Oct 18 '13 at 04:08
  • 3
    The reason why the question you linked doesn't have an answer is because that's definitely a wrong approach and will get you nowhere. Try explaining what's wrong with the CSS in different browsers, or possibly post a jsfiddle that illustrates your problem. There's certainly a good solution for it, but detecting OS is not it. – tomca32 Oct 18 '13 at 04:21
  • I agree that the approach OP is using is not a good approach but is that a good enough reason to down vote the question? – j03w Oct 18 '13 at 05:26

1 Answers1

0

I'm not sure why you're getting so many down ranks. Perhaps you should have explained your reasoning better. Nonetheless, this should take care of you, though it's old so you may need to update it in some cases. For broad detection, however, it'll work just fine.

Basically, it detects the browser via JS and appends a class to the body, which you can then test for in CSS.

http://rafael.adm.br/css_browser_selector/

Imperative
  • 664
  • 9
  • 17
  • 1
    Does this script do what the OP asked for? Possibly. Is this the wrong approach to solving cross platform CSS issues? Absolutely! – Steve Oct 18 '13 at 05:17
  • I couldn't agree with you more. It's a stopgap I've used to solve cross-browser typography issues with line height in poorly coded commercial themes when a client wanted to pay bottom dollar. I do a lot of band-aid work for SEO firms that fits this description. It's not ideal but it does do what the OP asked. I'm not going to hold back the option, when asked, simply because it's not the ideal approach. – Imperative Oct 19 '13 at 17:28
  • Fair enough. And I did not downvote exactly for that reason. It is a valid answer. But I cannot in good conscience upvote this answer either. :) – Steve Oct 19 '13 at 20:04
  • 1
    I appreciate your rational approach to things then. It's always frustrating to get a downvote for answering a question simply because it's not the ideal solution in a perfect scenario :) – Imperative Oct 20 '13 at 21:22