I've been trying to detect an iPhone or iPad purely by stylesheet. I tried the solution provided here by using @media handheld, only screen and (max-device-width: 480px) {.
However, this doesnt seem to work. Any ideas?
var isIOS = (function () { var iosQuirkPresent = function () { var audio = new Audio(); audio. volume = 0.5; return audio. volume === 1; // volume cannot be changed from "1" on iOS 12 and below }; var isIOS = /iPad|iPhone|iPod/. test(navigator.
You can quickly check to see if your device is Supervised by opening up the Settings app. On iOS 10 and newer devices, above your name at the top of the screen there will be text saying, “this iPhone is supervised and managed by”.
iPhone & iPod touch:
<link rel="stylesheet" media="only screen and (max-device-width: 480px)" href="../iphone.css" type="text/css" />
iPhone 4 & iPod touch 4G:
<link rel="stylesheet" media="only screen and (-webkit-min-device-pixel-ratio: 2)" type="text/css" href="../iphone4.css" />
iPad:
<link rel="stylesheet" media="only screen and (max-device-width: 1024px)" href="../ipad.css" type="text/css" />
This is how I handle iPhone (and similar) devices [not iPad]:
In my CSS file:
@media only screen and (max-width: 480px), only screen and (max-device-width: 480px) { /* CSS overrides for mobile here */ }
In the head of my HTML document:
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
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