I want to specify two slightly different background colors, one for Mac OS, one for Windows.
Using media queries are a popular technique for delivering a tailored style sheet (responsive web design) to desktops, laptops, tablets, and mobile phones. You can also use media queries to specify that certain styles are only for printed documents or for screen readers (mediatype: print, screen, or speech).
Media queries are commonly associated with CSS, but they can be used in HTML and JavaScript as well. There are a few ways we can use media queries directly in HTML.
there is no property to specify OS used to view webpage, but you can detect it with javascript, here is some example for detecting Operating system :
var OSName="Unknown OS"; if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows"; if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS"; if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX"; if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux"; console.log('Your OS: '+OSName);
got it?, now you can play with document.write
to write download stylesheet for specific Operating system. :)
another example, i assumed that you are using jquery.
if (navigator.appVersion.indexOf("Win")!=-1) { $(body).css('background','#333'); } else { $(body).css('background','#000'); // this will style body for other OS (Linux/Mac) }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With