Writing adaptive mobile Tips with REM

Source: Internet
Author: User

Direct on Dry Goods

1,DPR Apple cell phone pixel is 2 ordinary Andro is 1 that is 1 pixels under the apple Pixel point is Andro twice times so a need to 15x15 display of the image Andro only need to provide 15x15 to show clearly the Apple phone needs to 30x30 you can use to detect different types of mobile phone load different size map To ensure that the pixel

It is recommended to use Big Apple images and then convert them into different sizes.

2,rem Implementation method

Monitor screen size by viewport in the head:

<meta name= "viewport" content= "Width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" >

Use CSS3 @media in CSS to render in different size screens font-size to control the magnification of the page

Root HTML set Font-size to 67.5% 1rem to 10px

the use of the 125% that is 20px is due to the minimum display of Google Browser is 12px in order to facilitate debugging and I'm done finding out that using the 20 effect is OK.

When I do this, it's under the benchmark of 340, so on the 360 screen font-size should be 360/340 * 125% approx = 132.3 and so on

Html

{font-size:125%;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%; height:100%}

@media screen and (min-width:321px) and (max-width:360px) {html {font-size:132.3%;}

@media screen and (min-width:361px) and (max-width:375px) {html {font-size:137.9%;}}

@media screen and (min-width:376px) and (max-width:414px) {html {font-size:152.2%;}}

@media screen and (min-width:415px) and (max-width:435px) {html {font-size:160%;}}

@media screen and (min-width:436px) and (max-width:480px) {html {font-size:176.47%;}}

@media screen and (min-width:641px) and (max-width:769px) {html {font-size:250%;}}

3, note that mobile browsers generally have a minimum set of font display for example, you set the 5PX mobile browser in order to display clearly will follow the 10px display

because 10px is the minimum font required for this mobile browser , in order to display the 5px word

It is recommended to use the Scale property of CSS3 to simulate font size by scaling

Mobile phone side border also has a minimum display size you may see it in Google Chrome's phone simulation but the border disappears on your real phone.

It is recommended to set border to none using Css3 's Box-shadow property to simulate the border Box-shadow:inset 0 0.05rem #fff, inset 0.05rem 0 #fff, 0 0px. 05rem 0px bl ack;//, this is a black border.

4, the phone side does not support the hover property if you want to simulate the hover effect can take the binding Touchstart and Touchend simulation effect here li-active is the touch style

$ ('. Readboy-catalog li '). On (' Touchstart ', function (e) {$ (this). addclass ("li-active");});

$ ('. Readboy-catalog li '). On (' Touchend ', function (e) {$ (this). Removeclass ("li-active");});

5, mobile phone because of the need to load resources as little as possible so the use of jquery is not recommended here, but more lightweight zepto usage and jquery basically the same

6, Mobile-recommended carousel plugin Swiper styles and supports touch

And then slowly add it back.

Writing adaptive mobile Tips with REM

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.