Home > Web Front-end > JS Tutorial > Three ways to detect iPhone/iPad device orientation_javascript skills

Three ways to detect iPhone/iPad device orientation_javascript skills

WBOY
Release: 2016-05-16 16:51:38
Original
1347 people have browsed it

Use meta tag "viewport"

The viewport tag contains the following attributes:

Three ways to detect iPhone/iPad device orientation_javascript skills

In order to automatically detect and adapt to the screen width, device-with should be used instead Instead of setting a fixed value, in order to prevent the user from scaling the interface beyond the screen, you need to set maximum-scale,

Copy code Code As follows:



Use javascript script

The following script detects the orientation and adjusts the orientation by detecting the screen width:
Copy the code The code is as follows:



Above The script can be placed in the head section

Use CSS

Use CSS media query:
Copy code The code is as follows:



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template