0

Is it possible to detect whether a browser is running on iOS (I want to know if the device is an iPad) by using feature detect with Modernizr. Like it adds lt-ie8 class for IE8. I want to know what it sticks to <html> class if the device is an iPad.
I just want to add css classes exclusively for iPad.

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
Pratikshya
  • 192
  • 8
  • You can do so relying on screen resolution. http://stackoverflow.com/questions/3839809/detect-iphone-ipad-purely-by-css – ilyankou Dec 01 '15 at 05:06
  • 1
    Possible duplicate of [Possible to detect the \*type of mobile device\* via javascript or HTTP Headers?](http://stackoverflow.com/questions/158369/possible-to-detect-the-type-of-mobile-device-via-javascript-or-http-headers) – Cacho Santa Dec 01 '15 at 05:14
  • $useragent=$_SERVER['HTTP_USER_AGENT']; – user254153 Dec 01 '15 at 05:57

2 Answers2

1

You can use Modernizer to declare a class on the body or html tag when a person is viewing a certain browser.

From there you can declare those classes within your stylesheet.

https://modernizr.com/docs#using-modernizr-with-css

Samantha Ingram
  • 114
  • 1
  • 1
  • 9
0

via the user-agent header.

Copied from google search, I searched for user-agent ipad.

User-Agent String   Apple Product   iOS Version Build
Apple-iPad1C1/807.4 iPad    4.3.1   8G4 Mar 25, 2011
Apple-iPad1C1/808.7 iPad    4.3.2   8H7 Apr 14, 2011
Apple-iPad1C1/810.3 iPad    4.3.3   8J3 May 4, 2011
Apple-iPad1C1/811.2 iPad    4.3.4   8K2 Jul 15, 2011

Basically you should search for Apple-Ipad* in the user-agent header.

Sumit Maingi
  • 2,173
  • 3
  • 24
  • 44