Mobile development tips and flexible layouts

Source: Internet
Author: User

[Viewport basic knowledge]
Set the various information for the layout viewport:
1.width=device-width; Set viewpoint viewport width equal to device width;
2.initial-scale=1; page Default zoom ratio is 1 (Web page on handheld device, no default scaling)
3.minimum-scale=1 Web page Minimum zoom ratio is 1
4.maximum-scale=1 Web page Maximum zoom ratio is 1
5.user-scalable=no prohibit users from manually scaling Web pages (ios10+ device fails)

In the production of mobile phone station and responsive website, the webpage must add the following viewpoint setting statement

<meta name= "viewport" content= "width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1, User-scalable=no "/>



Prohibit the device to identify mobile phone number, mailbox, cancel Click to make phone calls and other events.


<meta name= "format-detection" content= "Telephone=no,email=no"/>


When IOS is added to the home screen, the WebApp title

<meta name= "Apple-mobile-web-app-title" content= "Jessiary app" >


When iOS is added to the home screen, enable WebApp full screen mode, remove top address bar and Bottom toolbar

<meta name= "apple-mobile-web-app-capable" content= "yes"/>


When IOS is added to the home screen, the WebApp top status bar color:
Black: White
White: Black
Black-translucent: Translucent. (When set to semi-transparent, the page fills the entire screen, and the top transparent status bar covers a strip of the topmost page)

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


When iOS is added to the home screen, the WebApp icon

<link rel= "apple-touch-icon-precomposed" href= "https://m.360buyimg.com/mobilecms/s80x80_jfs/t5965/339/ 3633548361/13799/cd4d0416/5954cf81n3294a71c.png "/>


Set up your browser and use the latest IE or chrome to compile;
>>> This sentence Set statement, not dedicated to the mobile phone, the general PC page needs to be set.

<meta http-equiv= "x-ua-compatible" content= "ie=edge,chrome=1"/>

<style type= "Text/css" >
body{
[Phone-side font style]
1, the general mobile phone does not support Microsoft Ya-black font.
2, the Chinese font is generally not set, using the system default.
3, English font is generally set to Font-family:helvetica;

Font-family:helvetica;
Set user cannot select text;
1, the mobile phone can not be long-press selection;
, PC can not use the mouse to select;

-webkit-user-select:none;
-moz-user-select:none;

}
input{
Remove the default appearance of the form, the phone, the PC can use


Appearance:none;
-webkit-appearance:none;
-moz-appearance:none;
color:red;
}


Setting the properties of a placeholder

Input::-webkit-input-placeholder {
color:red;
}
Input:focus::-webkit-input-placeholder {
Color:blue;
}
Input:-ms-input-placeholder {//ie10+
color:red;
}
Input:-moz-placeholder {//firefox4-18
color:red;
}
Input:focus::-moz-placeholder {//firefox19+
color:red;
}
img,a{
Disable hyperlinks and pictures, long time popup menu
-webkit-appearance:none;
}

[Flex Flexible Layout]
1, understand two basic concepts:
Container: A parent element that needs to add a resilient layout;
Project: Each child element in a resilient layout container, called a project;

2, the use of flexible layout?
① Add Display:flex/inline-flex to the parent container, and the container content can be displayed in a flexible layout instead of the normal document flow;
After the ② container is added to the elastic layout, only the container content is flexible, and the container itself is positioned in the document flow in accordance with the regular document flow;
③display:flex; The container is displayed as a block-level element after the elastic layout is added;
Display:inline-flex; The container is displayed as a row-level element after the elastic layout is added;
When ④ is set to flex layout, the float, clear, and vertical-align properties of the child elements are invalidated. However, the position attribute is still in effect.

3, acting on the relevant properties of the container;
The ①flex-direction property determines the direction of the spindle (that is, the direction in which the item is arranged).
Row (default): The spindle is horizontal, starting at the left;
Row-reverse: Spindle in the horizontal direction, beginning at the right end;
Column: The spindle is in the vertical direction, starting at the top edge.
Column-reverse: The spindle is in the vertical direction, starting at the bottom edge.

The ②flex-wrap property defines how to wrap a line if one of the axes does not fit.
NoWrap (default): No Line break. When the container width is not enough, each item will be extruded width;
Wrap: Wrap, and the first line is at the top of the container;
Wrap-reverse: Line break, and the first line is at the bottom of the container.

③flex-flow is an abbreviated form of flex-direction and Flex-wrap, with the default value: Flex-flow:row wrap;

The ④justify-content property defines how the item is aligned on the spindle.

>>> This property is closely related to the spindle direction. The spindle direction is: row-beginning on the left, the row-reverse-beginning on the right, the column-beginning on the top, the column-reverse-beginning in the bottom

Flex-start (default): The project is at the start of the spindle.
Flex-end: The project is at the end of the spindle.
Center: Center
Space-between: Justified, the interval between items is equal. (Start and end items, no interval with parent container edge)
Space-around: The intervals on each side of the item are equal. Therefore, the interval between items is one times larger than the interval between items and borders. (Initial and final items, with a certain interval from the edge of the parent container)

The ⑤align-items property defines how the item is aligned on the intersection axis.
Flex-start: The start alignment of the intersection axis.
Flex-end: The end alignment of the intersection axis.
Center: The midpoint alignment of the intersection axis.
Baseline: The baseline alignment of the first line of text for the item. (The line height of the text, the font size affects the baseline of each line)
Stretch (default): If the item is not set to height or auto, it fills the height of the entire container.


The ⑥align-content attribute defines the alignment of multiple axes. If the item has only one axis, this property does not work.
(You can use align-content instead of Align-items when the item is changed to multiple lines)
Flex-start: Aligns with the starting point of the intersection axis.
Flex-end: Aligns with the end of the intersection axis.
Center: Aligns with the midpoint of the intersection axis.
Space-between: aligned with the intersection axis and evenly spaced between the axes.
Space-around: The intervals between each axis are equal. Therefore, the spacing between the axes is one times larger than the interval between the axes and the border.
Stretch (default): The axis fills the entire cross axis.


4, for the properties on the project:
The ①order property defines the order in which items are arranged. The smaller the number, the higher the alignment, and the default is 0.
The ②flex-grow property defines the magnification of the item, which defaults to 0, that is, if there is space left, it is not zoomed in.
The ③flex-shrink property defines the scaling of the project, which defaults to 1, which means that if there is not enough space, the project shrinks.
④flex-basis defines the spindle space occupied by the project. (If the spindle is horizontal, setting this property is equivalent to setting the width of the item.) The original width will be invalidated. )

The ⑤flex property is shorthand for Flex-grow, Flex-shrink, and flex-basis, and the default value is 0 1 auto. The latter two properties are optional.
This property has two shortcut settings: auto= (1 1 Auto)/none= (0 0 Auto)

⑥align-self: Defines how individual items are arranged on the cross axis, overwriting the Align-items property on the container.
Property value: Same as Align-items, the default value is auto, which represents the Align-items property value that inherits the parent container.

Mobile development tips and flexible layouts

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.