Principle:
When the user rotates the screen, it goes into your listening method and then window.orientation to get the status of the current screen:
0-Vertical screen
90-Rotate the horizontal screen counterclockwise
-90-rotate the horizontal screen clockwise
180-vertical screen, upside down
If you do not want users to use a horizontal screen view of your page, you can monitor the device rotation time inside the body using CSS3 inside the transition in the rotation to keep the page vertical.
A page on a mobile device that has a Orientationchange event when the screen is rotated. You can increase the listener for this event to the BODY element:
<body onorientationchange= "updateorientation (); >
Monitor form changes to monitor phone screen
@media screen and (orientation:portrait) {
css[vertical definition Style]
}
@media screen and (Orientation:landscape) {
css[horizontal definition Style]
}
CSS3 Judge mobile phone horizontal screen vertical screen