Introduction of Debugging Tools (Chrome Emulation)
1.Device (device dependent)
Custom dimensions, network (web emulation), useagent (browser information), scaling
2.Media (Media)
3.Network (network emulation)
4.Senors (Sensor)
Warp Latitude, gyroscope
Second, local server Setup
1. Build Server | | Hbuilder
2. Connecting devices on the same network
* Firewall off
Three, pixel ratio
1. Dot Point (abstract unit)
2. Pixel Rendering (rasterization)
3. Physical pixels (resized)
4.DPI, PPI
5. Get pixel ratio (window.devicepixelratio)
Iv. Viewport (viewport)
1.width device width [pixel_value | device-width]
2.user-scalable whether to allow scaling (No | | Yes
3.initial-scale Initial Scale
4.minimum-scale minimum scale allowed for scaling
5.maximum-scale maximum scale allowed for scaling
6.TARGET-DENSITYDPI (retired)
7. Dynamic control ratio 1/pixel ratio
V. Pre-preparation
1. Layout Unit Introduction Selection
2. Default Style Handling
-webkit-tap-highlight-color:transparent;
Input{-webkit-appearance:none;} /* Remove input Default style */
3. Frame Construction
4. Adjustment of the screen
Getboundingclientrect (). Width
Resize.orientationchange
Vi. Media Enquiry
All media
Braille Braille Tactile Devices
Embossed Braille Printer
Print handheld device
Projection Print Preview
Screen Color Equipment
Speech ' auditory ' similar media types
TTY non-pixel-compatible devices
Tv
Vii. characteristics of the media
Min-width resolution width greater than or equal to device is worth recognizing
Max-width when the resolution width is less than or equal to the device value
Orientation:portraint Vertical Screen
Orientation:landscape Horizontal Screen
-webkit-min-device-pixel-radio:2 pixel ratio
Eight, key words
And and, with (connection media features)
Not excludes the specified media type
Only specify a specific media type (often used for devices that do not support media features but that support media types)
Nine, style reference
External style sheet link[media= "all and (min-width:600px)"]
@import @import URL (index.css) all and (min-width:600px)
Ten, the normal size
@media all and (min-width:1200px) {//Large resolution (PC resolution, TV)}
@media all and (min-width:850px) and (max-width:1199px) {//Medium resolution (PC Small Resolution | | pad)}
@media all and (min-width:700px) and (max-width:849px) {//pad Resolution}
@media all and (min-width:480px) and (max-width:699px) {//High Resolution mobile Device | | Low resolution FLAT Panel}
@media all and (MAX-WIDTH:479PX) {//Mobile device}
Add:
First, mobile development needs
1. Make the width of the page consistent with the width of the access device Device-width
2. Do not allow the user to scale the page user-scalable = no
3. Control pixel ratio
(How to make 1px do 1px things?) A 1:1 pixel restore B as far as possible and the device resolution is consistent)
Control pixel ratio by JS:
<script>
Get pixel ratio
var pixelratio = 1/window.devicepixelratio;
Dynamically set the viewport via JS (viewport)
document.write (' <meta name = "Viewport" content = "width = Device-width,initial-scale = ' +pixelratio+ ', Minimum-scale = ' +pixelratio+ ' "/> ')
</script>
Second, mobile layout steps
1. Determine the size (design draft) and also have to meet the size of the simulator under the first preview
2. Build a general framework
Three, unit comparison
PX Absolute (fixed) unit
Cons: Fixed values in any case, resulting in layout misalignment under different size devices
% relative units (which will have a change in impact) are calculated in relation to the parent (self) size
Disadvantage: Can determine the scope of or relatively good calculation, for the less well-defined value of the place is not good use of the percentage, and will cause deformation
EM relative units (there will be changes in influence) em= current font size
Disadvantage: Depending on the current container font size changes, if each container font size is inconsistent, then the calculation will be very troublesome
rem r=root em= Font size relative units depend only on HTML font size
Four, dynamically set the font size
<script>
Condition: The larger the size, the larger the font, the smaller the size, the smaller the font
Get HTML node
var html = document.getelementbytagname (' HTML ' [0]);
Get screen width
var pagewidth = Html.getboundingclientrect (). width;
Screen width/Fixed value = reference value
Html.style.fontsize = pagewidth/10 + ' px ';
</script>
The method of fixed positioning on the mobile side:
Html{width:100%;height:100%;overflow:hidden;}
Body{width:100%;height:100%;overflow:auto;}
The elements that need to be positioned use position:absolute;top:0;left:0;
First Lesson Mobile & responsive