1. Events and styles for screen rotation
Event
Window.orientation, value: Plus or minus 90 indicates that the horizontal screen mode, 0 and 180 are displayed as vertical screen mode;
Window.onorientationchange = function () {
Switch (window.orientation) {
CASE-90:
Case 90:
Alert ("Horizontal screen:" + window.orientation);
Case 0:
Case 180:
Alert ("Vertical screen:" + window.orientation);
Break
}
}
Style
Style used when vertical screen
@media all and (orientation:portrait) {
. css{}
}
Styles used when traversing a screen
@media all and (Orientation:landscape) {
. css{}
}
2.audio elements and video elements do not play automatically in iOS and Andriod
Solution: Touch screen is broadcast
$ (' HTML '). One (' Touchstart ', function () {
Audio.play ()
})
3. Shake and Shake function
HTML5 Devicemotion: The event of moving sensor data is encapsulated, which can get the motion acceleration of mobile phone.
4. Mobile photos and upload pictures
<input type= "File" > 's Accept Property
<!--Select Photos--
<input type=file accept= "image/*" >
<!--Select Video--
<input type=file accept= "video/*" >
Usage Summary:
- iOS has photos, videos, and local image selection features
- Some Android only choose local picture function
- Winphone not supported
- The input control looks ugly by default
5. Eliminate Transition splash screen
. css{
/* Set how inline elements are rendered in 3D space: Reserved 3d*/
-webkit-transform-style:preserve-3d;
/* (sets whether the reverse side of the element being converted is visible when facing the user: hidden) */
-webkit-backface-visibility:hidden;
}
Turn on hardware acceleration
- Resolve page Flash White
- Keep your animations flowing
. css {
-webkit-transform:translate3d (0, 0, 0);
-moz-transform:translate3d (0, 0, 0);
-ms-transform:translate3d (0, 0, 0);
Transform:translate3d (0, 0, 0);
}
Several elements of designing high-performance CSS3 animations
- Use composition attributes transform and opacity to design CSS3 animations whenever possible
- Use position left and top to locate
- Using Translate3d to turn on GPU acceleration
6. Remove the Voice input button on Android
Input::-webkit-input-speech-button {Display:none}
Common problems with mobile web development