One, the adaptation problem Solution: Flow layout + viewport
1. Flow-type layout
Percent layout, by setting the width of the box as a percentage to scale according to the size of the screen, the feature is not limited by fixed pixels, the content is filled to both sides
2, viewport
On the mobile side of the area used to host the page, is our visual window, also known as viewport (viewport), this area can be set height width, can be scaled down, and can be set whether to allow users to scale themselves.
<meta name = "Viewport" > let the browser know that the Viewport,viewport is only recognized on the mobile side
3. Viewport parameters
Width: Defines viewport widths, with a special value device-width the width of the current device
Initial-scale: Default initial zoom ratio
Settings 1.0, and PC-side page display scale consistent, 1:1 display on the mobile side
User-scalable: Whether users are allowed to scale their own 1-yes,0-no
Maximum-scale: Maximum zoom ratio
Minimum-scale: Minimum zoom ratio
4. Build a standard mobile Web development page
<meta name = "Viewport" content = "width = Device-width,initial-scale = 1.0, user-scalable = 0" >
Shortcut key-META:VP
Ii. issues to be noted in writing projects
Base style definition: Reset CSS resets default, browser-brought some styles (all labels and pseudo-classes) to keep the various terminal display consistent
1. Special settings on the mobile side
① clearly click the Highlight effect
-webkit-tap-highlight-color:transparent;
② set the width of all boxes to start with a border
A percentage layout is typically used on the mobile side, so if you use border or padding, the width of the container will be greater than the width of the screen to produce scrollbars.
-webkit-box-sizing:border-box;
Box-sizing:border-box;
③ clear the default style of input
- Webkit-appearance:none;
2, the minimum width, the maximum width limit
min-width:300px; Suitable for small screen equipment, in order to have a better layout effect.
max-width:640px;//ensure that the page is in the larger size of the device to ensure that the effect of the page is clarity
3, physical pixel and icon blur problem
solution, using the compression icon size to solve.
If IMG is used to directly set the width of the high way to compress.
If the background is using a setting background-size the way to compress
4. Search button Call
Call input method on mobile side, pop-up keypad enter will change to search button
<form action = "#" >
<input type = "search" placeholder = "hint"/>
</form>
5. Structural pseudo-class principle---same type selector
E:first-of-type matches the first element in the same type, E.
E:last-of-type matches the last element in the same type E.
E:nth-of-type (n) matches the nth element e in the same type.
Mobile Development web First day