rem是相对于html的font-size的大小单位,在做移动端,不同屏幕下自适应很好用,下面是基于不同分辨率,生成html font-size大小的代码
1 | /* |
转换成css为:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18html {
font-size: 20px;
}
@media only screen and (min-width: 400px) {
html {
font-size: 21.33333333px ;
}
}
@media only screen and (min-width: 414px) {
html {
font-size: 22.08px ;
}
}
@media only screen and (min-width: 480px) {
html {
font-size: 25.6px ;
}
}
注:less 转换方法 sudo npm install less -g
lessc styles.less