Mobile-screen adaptation issues

Source: Internet
Author: User

In order to do mobile adaptation, CSS3 out a new unit Rem,rem is relative to the root element

html{font-size:20px}, default is 20px;

@media only screen and (max-width:1220px) and (min-width:992px) {
html{
font-size:50px;
}
}

It means that the size of the screen in the 992px and 1220px of the font size of the HTML is 50px, according to the actual situation extrapolate list the mainstream screen size, if you think it is not rigorous enough to use JS to dynamically set the font size of HTML;

<script>

document.getElementsByTagName (' HTML ') [0].style.fontsize=window.innerwidth/10+ ' px ';

</script>

10 can also be changed to do other, take 10 is for convenient calculation;

If the unit conversion trouble, you can use less or sass and other preprocessor to complete; Of course, the unit can also use VW or VH to calculate, 1VW is the screen width of the 1%;1VH is the screen height of 1%;

Layout can be used in the layout of flex;

Several problems and solutions to mobile development:

One: HD image processing

IMG 100px *100px

HD screen 200DP*200DP rendering Blur, dpr=2 in case

Solution 50px *50px Get the right results

Two: one pixel border

The same is the problem of HD screen, the root cause is 1px use 2DP to render

border:0.5px This notation only works in iOS8;

Solution:

. Sidebar. Folder Li{position:relative}

. folder li+li:before{

Position:absolute;

top:-1px;

left:0;

Content: ";

width:100%;

height:1px;

border-top:1px solid #ddd;

-webkit-transform:scaley (0.5);

}

Mobile-screen adaptation issues

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.