移动端web css适配
一位大神写的:
html{font-size:100px;font-size:calc(1000vw/32);background-color:#E1E1E1;} @media all and (max-width:320px){ html{font-size:100px;} } @media all and (min-width:640px){ html{font-size:200px;} } body{min-width:320px;max-width:640px;margin:0 auto;color:#333;padding:0;font:normal .12em/1.6 "Microsoft YaHei",Verdana,Tahoma;background-color:#FFF;}
vw Viewport宽度, ** 1vw ** 等于viewport宽度的1%
vh Viewport高度, ** 1vh ** 等于viewport高的的1%
vw和vh会随着viewport变化自动变化,再也不用js控制全屏神马的了
IE10+ 和现代浏览器都支持这两个单位
CSS
calc()函数可以和<lenght>、<frequency>、<angle>、<time>、<number>或<integer>一起使用,它可以执行+、-、*和/等数学运算,并将计算结果和前面提到的测量单位组合为一个新的CSS属性值。
根据自己的需求更改了一下
html { font-family: "Heiti SC", "Microsoft YaHei"; font-size: 20px; outline: 0; -webkit-text-size-adjust: none; } @media only screen and (min-width:320px){html{font-size: 17.0667px !important} } @media only screen and (min-width:414px){html{font-size: 22.08px !important} } @media only screen and (min-width:480px){html{font-size:25.6px !important} } @media only screen and (min-width:569px){html{font-size: 30.3467px !important} } @media only screen and (min-width:641px){html{font-size: 34.1867px !important} } html{font-size: calc(2 * 100vw / 37.5) !important} //如果在低版本安卓下失效将使用上面的媒体查询
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。
- 上一篇: @media 移动端屏幕适配
- 下一篇: Mysql服务器无法存emoji表情的解决方案