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