Common problems with mobile web development

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.