H5 attention to detail on the mobile side

Source: Internet
Author: User

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

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.