Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect iPhone/iPad purely by css

Tags:

css

iphone

ipad

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?

like image 780
FLX Avatar asked Oct 01 '10 13:10

FLX


People also ask

How can I tell if my iPhone is Javascript or iPad?

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.

How can you tell if your iPad is being monitored?

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”.


2 Answers

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" /> 
like image 169
Olivier Payen Avatar answered Sep 25 '22 19:09

Olivier Payen


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"> 
like image 44
Bart Avatar answered Sep 25 '22 19:09

Bart