At this time last year, began to slowly touch the mobile side, touching the mobile side is not early. But then find the relevant information is not a lot (no technology, can not find), only in the slowly groping the code to find ways! Remember that time has been tangled up why other people's pictures on the phone so clear, and we do is so vague, later listened to enlarge the picture, then use the code to reduce, only to ensure clear on the phone. (The issue of DPI, retina 2x is only later known).
Talk less, get to the chase!
The following are the knowledge points required by the mobile side:
1) The mobile screen is varied, DPI (pixel density) is different, the higher the image the clearer. And the average Android phone and iphone resolution of the basic ratio of 1:2. So I know why the icons on the Apple are blurred, because the default is magnified by twice times the size to render the page!
At present, our mobile phone design for the iphone5s resolution 640*1136, and in transduction, the use of 320 of the width of the production. Why is it so?
The reason or because of the high resolution of the retina screen, reduce the size of the image to ensure the HD 1:2 ratio. If conditions permit, it is recommended to make multiple sets of icons, which are then introduced through the media.
Detailed steps to refer to the desert: toward the retina (retina) of the web era
2) Viewport: Visible area, this method has multiple settings setting parameters:
width = [Pixel_value | device-width] // width (optional actual width value or second parameter)height = [Pixel_value |device-height]< c3/>// height initial-scale = float_value // initial ratio Minimum-scale = float_value // min ratio maximum-scale = float_value // Max scale user-scalable = [yes | no] // whether to scale
This parameter sets the visible area, scale size, and usually uses the following code:
<meta name="viewport" content="width=device-width; initial-scale=1.0;maximum-scale=1.0; User-scalable=no; "/>
Width with device width, default and maximum minimum scale is 1, do not allow zooming! Normally we will also set the following parameters for the iphone:
//Hide the Address bar status bar<meta name="Apple-mobile-web-app-status-bar-style"Content="Black"/>//offline applications (depends on demand)<meta name="apple-mobile-web-app-capable"Content="Yes"/>//prohibit identification of phone numbers<meta name="format-detection"Content="Telephone=no"/>
3) font size, it is best to use the size EM as the production unit, not the PX in the mobile phone side. At present, the resolution of a wide range of mobile phones, some phone font default is 24px for the smallest unit, and some 16px. All in order to unify the font, the following code is usually set in the style:
html, body { font-size:%}
Ensure that the font size is installed by default size setting, and then all fonts are calculated in EM size, which guarantees that the font will not have a different size request when cross-device. and the font px to EM conversion method, you can refer to the desert:css powerful em
4) Fluid layout (fluid layout), currently known to the mobile device screen too much, so the layout can not use fixed layout 1024px, and what is the fluid layout? The flow layout of the measurement units and fixed layout of the measurement units, the fluid layout is used as a percentage, that is, as the device screen changes, the layout of the percentage of the corresponding changes, improve the flow of the page. Introduction to fluid layout and various layouts, reference Desert: Responsive Design: Fluid layout
at the same time, fluid layout is closely related to media queries, and media properties allow different devices (such as screens, printers) to specify different style sheets, and to specify the corresponding style based on the device's wide screen width. Fluid layouts and media queries combine to build better mobile pages. What the? Media query do not know, then please see the Desert article Introduction:CSS3 Media Queries
Mobile knowledge points, in fact, said much less, just need to change from the past production way over! A lot of mobile-related text, in the desert site has a corresponding introduction, this article is mainly to collate the required knowledge points, and then introduce the mobile side of the partial attention issues:
1) Font selection: iOS 4.0+ uses the English font Helvetica Neue, before the iOS version is degraded using Helvetica. The Chinese font is set to Chinese blackbody stheiti.
{ font-family: "Helvetica Neue", Helvetica, Stheiti, Sans-serif;}
2) Set the global CSS style to avoid long press of the pop-up menu and the selected text in the diagram.
{ -webkit-touch-callout: None*/*/} { - Webkit-user-select: none; /* */ user-select: none;}
Various performance optimization aspects, reference: Mobile Development Specification Overview
3) percent size, encountered Padding/border result in page width is not expected effect, you can use the following CSS style, change the box model:
{ box-sizing:border-box/**/}
4) Click <a> Link or bind the Click event, a virtual border appears in the mobile part of the Android, using the following CSS styles to clear the border:
{ -webkit-tap-highlight-color:rgba (255,0,0,0);}
5) iphone input box appears strangely rounded style, iphone default style, workaround:
{ -webkit-appearance: none;}
That was why it took a long time to find the answer in a well-known foreign site Stackexchange. Original: Turn off Iphone/safari INPUT element rounding
6) scripting issues, using the Click event on the mobile side, there will be a 300ms delay, so it's best to use touch event touch. See: 300 milliseconds Click the ins and outs of the delay. And the mobile side, it is best not to use the Jquery/jquery mobile framework, because it is too big for the page performance is not good, suggest zepto.js, syntax jquery similar, quick to get started.
7) involving animations, consider whether or not to use Translate3d to trigger GPU acceleration because some animations perform faster on the mobile side, which can improve smoothness
{ -webkit-transform: translate3d (0, 0, 0); -moz-transform: translate3d (0, 0, 0); -ms-transform: translate3d (0, 0, 0); transform: translate3d (0, 0, 0);}
If the animation process flashes (usually at the beginning of the animation), you can try the following hack:
{ -webkit-backface-visibility: hidden; -moz-backface-visibility: hidden; -ms-backface-visibility: hidden; backface-visibility: hidden; -webkit-perspective: +; -moz-perspective: +; -ms-perspective: +; Perspective: +; }
Specific reference Masaki article: using CSS to turn on hardware acceleration to improve website performance (go), not finished, subsequent updates.
Summary: This article for mobile-related data collation, knowledge is limited, you are welcome to criticize the guidance!
Summary of mobile development knowledge points