1.
Max-width used on PC-side pages, max-device-width on mobile devices
2.
Device-pixel-ratio Device pixel ratio
3. Equipment own Unit-physical unit Dp/dip
CSS pixels px
Device pixel ratio is 1 1px = = 1dp/1dip
Device pixel ratio is 2 1px = = 4dp/4dip
Device pixel ratio is 3 1px = = 9dp/9dip
/* Normal display (device pixel ratio is less than or equal to 1) Use 1 time times the figure */
. css{
Background-image:url (img_1x.png);
}
/* HD display (device pixel ratio greater than or equal to 2) use twice times graph */
@media only screen and (-webkit-min-device-pixel-ratio:2) {
. css{
Background-image:url (img_2x.png);
}
}
/* HD display (device pixel ratio greater than or equal to 3) use 3 times times graph */
@media only screen and (-webkit-min-device-pixel-ratio:3) {
. css{
Background-image:url (img_3x.png);
}
}
4.
<meta name = "Viewport" content= "Width=device-width,initial-scale = 1.0,user-scalable = no" >
<!--responsive page does not allow users to zoom--
<meta name= "Viewport" content= "width = Device-width,initial-scale = 1.0"/>
<!--user-scalable:no Prohibit user Zoom--
<!--[If Lt IE 9]>
<script src= "Http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js" ></script>
<! [endif]-->
5, @media comparison:
@media screen and (max-width:1000px) {
/* When the width of the display area is less than or equal to 1000, the following CSS works */
div{
width:980px;
background:red;
}
}
@media all and (min-width:1000px) {/* window width is greater than or equal to 1000, the style here works */
. header {
width:1000px;
margin:0 Auto;
}
}
@media screen and (max-width:1000px) {
/* When the width of the display area is less than or equal to 1000, the following CSS works */
div{
width:980px;
background:red;
}
}
6.
H5 attention to detail on the mobile side