Yesterday's "Mobile Web development Skills" in this article, we have a good response, because these problems in the daily writing of mobile pages, often encountered. So the article is still super practical, so we continue today to share the mobile web development skills, we hope to help.
PS: Do not let the small partner write the mobile end of the first time like the following the face of the force haha ...
first, enable WEBAPP full screen mode (IOS)
When the site is added to the home screen and then clicked to start, you can hide the address bar (jumping from the browser or entering the link does not have this effect)
<meta name= "apple-mobile-web-app-capable" content= "yes"/><meta name= "Apple-touch-fullscreen" content= "Yes "/><!--more-->
Second,app icon added to the main screen
There are two slightly different ways to specify the path to the icon after the Web app is added to the home screen:
<!– Design Original –>
<link href= "Short_cut_114x114.png" rel= "apple-touch-icon-precomposed" >
<!– Add a highlight effect –>
<link href= "Short_cut_114x114.png" rel= "Apple-touch-icon" >
* Apple-touch-icon: IOS6 and below will automatically add a layer of highlight to the icon (IOS7 has begun to use a flat design style) * apple-touch-icon-precomposed: Use the "Design original icon"
third, priority to use the latest version of IE and Chrome
<meta http-equiv= "x-ua-compatible" content= "ie=edge,chrome=1"/>
IV. Mobile Touch Event (differentiate between WebKit and Winphone)
Touch events that trigger when a user's finger is placed on a mobile device that slides on the screen
The following support WebKit
- touchstart--occurs when the finger touches the screen. No matter how many fingers are present
- touchmove--a continuous trigger when the finger is sliding on the screen. Usually we slide the page again, and the Preventdefault () that invokes the event can prevent the default from happening: Prevent page scrolling
- touchend--triggered when the finger leaves the screen
- The touchcancel--system stops tracking when the touch is triggered. For example, in the process of touching a sudden page alert () A prompt box, which will trigger the event, this event is less used
The following support Winphone 8
- mspointerdown--occurs when the finger touches the screen. No matter how many fingers are present
- mspointermove--a continuous trigger when the finger is sliding on the screen. Usually we slide the screen again, will call the CSS Html{-ms-touch-action:none;} You can prevent the default from happening: Prevent page scrolling
- mspointerup--triggered when the finger leaves the screen
Fifth, the Mobile click Screen generates 200-300 MS Delay response
Web pages on mobile devices are 300ms delayed, and playing can cause button click Delay or even click Invalidation.
The following are historical reasons:
In 2007, Apple released the first iphone on the iOS system with safari in order to apply to the PC-side of the large screen can be better displayed on the mobile phone, using double-click Zoom (double tap to zoom) scheme, such as you on the phone with a browser to open a Web page on a PC , you may see the page content although can fill the entire screen, but the font, pictures are very underestimated, at this time you can quickly double-click on a part of the screen, you can see the part of the enlarged content, double-click to return to the original state.
Double-click Zoom refers to a quick click on the screen with your finger two times, and IOS comes with a Safari browser that zooms the page to its original scale.
The reason for this is how the browser needs to determine the quick click, when the user clicks an element on the screen, such as a jump link <a href= "#" ></a>, where the browser captures the click First, However, the browser can not determine whether the user is simply to click on the link or double-click on the area to zoom, so, after capturing the first click, the browser will hold a period of time t, if the user does not make the next click in the t time interval, then the browser will do a click Jump link processing, If the user makes a second click in the T-time, the browser disables the jump and instead zooms in on that portion of the area's page.
So how much does this time interval t have? Under iOS Safari, it's about 300 milliseconds. This is the origin of the delay. The consequences of the user simply click on the page, the page takes a while to respond, give the user a sense of slow experience, for the web Developer, the page JS capture Click event callback function processing, requires 300ms before it takes effect, also indirectly lead to affect the processing of other business logic.
Solution:
- Fastclick can resolve 300ms latency of click events on the phone
- Zepto's Touch module, the Tap event is also designed to address latency issues in the Click
Response Order of touch events
1, Ontouchstart
2, Ontouchmove
3, Ontouchend
4. onclick
Solve problems with 300ms latency, or you can speed up response to events by binding Ontouchstart events
How to remove the translucent gray matte that is generated when elements in the iOS system are touched
iOS users click on a link, a translucent gray matte appears, if you want to disable, you can set the alpha value of-webkit-tap-highlight-color to 0, that is, the last digit of the property value is set to 0 to remove the translucent gray matte
A,button,input,textarea{-webkit-tap-highlight-color:rgba (0,0,0,0;)}
How to remove the borders created when elements are clicked on part of the Android system
Android users click on a link, there will be a border or translucent gray matte, different manufacturers defined the amount of the effect is not the same, you can set the alpha value of-webkit-tap-highlight-color 0 to remove some of the machine's own effect
a,button,input,textarea{-webkit-tap-highlight-color:rgba (0,0,0,0;)-webkit-user-modify: Read-write-plaintext-only;}
-webkit-user-modify has a side effect, is that the input method can no longer enter multiple characters
In addition, some models can not be removed, such as Millet 2
For the button class there is another way, do not use a or input tags, directly with the DIV tag
Eighth,Mobile photos and uploading pictures
- <input type= "File" > 's Accept Property
- <!– Select Photo –>
- <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
Ninth, eliminate transition splash screen
. css{/* Sets how embedded elements are rendered in 3D space: Reserved 3d*/-webkit-transform-style:preserve-3d; /* (sets whether the back 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 synthetic attributes transform and opacity as much as possible to design CSS3 animations,
- Use position left and top to locate
Using Translate3d to turn on GPU acceleration
Tenthaudio elements and video elements do not play automatically in iOS and Andriod
Solution: Touch screen is broadcast
$ (' HTML '). One (' Touchstart ', function () {Audio.play ()})
Today we will share these 10, we have the need for their own collection Oh!
========================================================
Xiao Yue Blog
Http://www.aliyue.net
Web
========================================================
Mobile Web Development Tips (follow-up)