Tips for web Mobile development

Source: Internet
Author: User

1. Determine the type of mobile phone

var u = navigator.useragent;

var isandroid = u.indexof (' Android ') >-1 | | U.indexof (' Adr ') >-1; Android

var Isios =!! U.match (/\ (i[^;] +;( U;)? Cpu.+mac OS x/); iOS terminal

2. The default inner shadow of the input box under iphone and ipad

element{

-webkit-appearance:none;

}

3. Translucent gray matte when touching elements under iOS and Android

Element {

-webkit-tap-highlight-color:rgba (255,255,255,0)

}

However, this method is not valid on Samsung's machine, there is a compromise method is to replace the page non-real jump link a tag to other tags, can solve the problem.

4.1px Frame of Retina screen

element{

Border-width:thin;

}

5. Top status bar background color (iOS)

sets the background color of the status bar, only the "Apple-mobile-web-app-capable" content= "yes" is effective.

<meta name= "Apple-mobile-web-app-status-bar-style" content= "Black"/>

Content parameters:
Default: The status bar background is white.
Black: The status bar background is dark.
Black-translucent: The status bar background is translucent. If set to default or black, the page content starts at the bottom of the status bar. If set to Black-translucent, the page content fills the entire screen, and the top is obscured by the status bar.

6. Set the cache

<meta http-equiv= "Cache-control" content= "No-cache"/>

mobile pages are usually cached after the first load, and then each refresh uses the cache instead of going back to the server to send the request. If you do not want to use the cache, you can set No-cache.

7. Desktop icons

<link rel= "Apple-touch-icon" href= "Touch-icon-iphone.png"/>

<link rel= "Apple-touch-icon" sizes= "76x76" href= "Touch-icon-ipad.png"/>

<link rel= "Apple-touch-icon" sizes= "120x120" href= "Touch-icon-iphone-retina.png"/>

<link rel= "Apple-touch-icon" sizes= "152x152" href= "Touch-icon-ipad-retina.png"/>

8, iOS input keyboard event KeyUp, KeyDown, keypress support is not very good

Workaround: You can use the HTML5 Oninput event to replace the KeyUp

9, Baidu prohibit transcoding
Baidu Mobile phone to open the page, Baidu may be on your page transcoding, to your page affixed to its ads, very disgusting. But we can use this meta tag to disable it:

<meta http-equiv= "Cache-control" content= "No-siteapp"/>

There may be other types of numbers that are also identified. We can turn off auto-recognition of phone numbers by following meta:

<meta name= "format-detection" content= "Telephone=no"/>
Turn on phone function

<a href= "tel:123456" >123456</a>
To turn on the SMS feature:
<a href= "sms:123456" >123456</a>

Similarly, we can also use the Tag property to turn on the long-by-email address pop-up message sending function:
<a Mailto:[email protected] ">[email protected]</a>

10. Click Delay

The Fastclick can resolve the 300ms latency of the Click event on the phone.
Zepto's Touch module, the Tap event is also designed to address latency issues in Click.


11, what is the retina display, brought about what problems
Retina: An ultra-high pixel density LCD screen, the same size of the screen display pixel points from 1 to multiple, such as on the same size of the screen, the Apple device's retina display, the pixel point 1 into 4.
when the bitmap in the HD display is magnified, the image becomes blurred, so the visual artwork on the mobile side is often designed as a traditional Twice times the PC.
The front-end response, then, is:
the picture cut out by the design is guaranteed to be an even number, and the image is reduced to the original 1/2 using Backgroud-size.
The sample width height is: 200px*200px, then the wording is as follows
. css{width:100px;height:100px;background-size:100px 100px;}
other elements of the value of the original 1/2, such as the visual version of the 40px font, the use of style is written as 20px.


12, WebKit form input box placeholder color value can change?

Input::-webkit-input-placeholder{color: #AAAAAA;}
Input:focus::-webkit-input-placeholder{color: #EEEEEE;}

13. Translucent Gray matte when elements are touched in the iOS system
iOS users click on a link and a translucent gray matte appears, and if you want to disable it, you can set the alpha value of-webkit-tap-highlight-color to 0, which means that 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;)}

14. Turn off iOS input auto-correction
and enter the default auto-initials in English, iOS also does a function, the default input method will turn on the automatic correction input, so that users often have to operate two times. If you do not want to turn this feature on, we can turn it off by using the input Tag property:
<input type= "text" autocorrect= "Off"/>

15. Suppress text scaling
The size of the text is recalculated when the mobile device is switched between the screen and the other, and is scaled accordingly, and when we don't need this, we can choose to disallow:
HTML {-webkit-text-size-adjust:100%;}

It is important to note that The property on the PC side has been removed, and the property must be set to ' meta viewport ' to take effect on the mobile side.

16. Disable selection on the mobile side
If you don't want the user to be able to select the content on the page, you can disable it in the CSS:

. user-select-none {
-webkit-user-select:none;
-moz-user-select:none;
-ms-user-select:none;
}

17. How to prohibit saving or copying images ( IOS)

    1. usually when you press and hold the image img on your phone or pad, the option to store the image or copy the image will pop up, and if you don't want the user to do so, you can disable it in the following ways:
      img {-webkit-touch-callout:none;}
    2. Mobile-defined Fonts

18, the three major mobile phone system font:
iOS system
The default Chinese font is Heiti SC
The default English font is Helvetica
The default number font is Helveticaneue
No Microsoft Ya-Black font
Android system
The default Chinese font is Droidsansfallback
the default English and digital fonts are Droid Sans
No Microsoft Ya-Black font
Winphone system
The default Chinese font is Dengxian (founder and other line body)
the default English and digital fonts are Segoe
No Microsoft Ya-Black font
each phone system has its own default font, and does not support Microsoft Black no need to define Chinese font for mobile phone without special requirement, use system default English fonts and digital fonts can be used Helvetica, three systems are supported.

19. How to reset the default appearance of WebKit form elements
. Css{-webkit-appearance:none;}

20, eliminate transition splash screen

. css{
-webkit-transform-style:preserve-3d;
-webkit-backface-visibility:hidden;
}
. css {
-webkit-transform:translate3d (0, 0, 0);
-moz-transform:translate3d (0, 0, 0);
-ms-transform:translate3d (0, 0, 0);
Transform:translate3d (0, 0, 0);
}


Design High Performance Several elements of CSS3 animation
A, use synthetic attributes transform and opacity as much as possible to design CSS3 animations,
B, do not use the position left and top to locate

C. using translate3d to turn on GPU acceleration

21, Tools recommended

1). Mobile-based framework
   Zepto.jsGrammar andjquery almost the same, will jquery basic will zepto~
   Iscroll.jsThe Resolve page does not support elastic scrolling and does not supportFixed problem ~ Realize pull-down refresh, slide screen, zoom and other functions ~
   Underscore.jsThe library provides a full set of functional programming functions, but does not extend anyJavaScript built-in objects.
   FastclickAccelerate Mobile-click Response Time
   Animate.cssCSS3 Animation effects Gallery
2). Sliding screen Frame
Suitable for sliding screen on the slide screen, left and right slide screen to switch page effect
   slip.js islider.js fullpage.js swiper
3). Waterfall Flow Frame
   Masonry
4). Other tools recommended
   Caniusesupported by BrowsersHTML5 Property Query
   PalettonColor Match

Tips for web Mobile 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.