前端基础类学习

移动端系列(适配)

2017-11-24  本文已影响16人  饥人谷_米弥轮
像素比

详细请参考:
http://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutions

视口
设置1:1像素比
let  ratio = 1 / window.devicePixelRatio
document.write('<meta name="viewport" content="width=device-width, initial-scale=' + ratio + ',maximum-scale=' +
ratio + ',minimum-scale=' + ratio + '">')
设置rem,根据屏幕大小自动调整适合该屏幕的像素
let $html = document.querySelector("html")

//获取文档宽度
let pageWidth = $html.getBoundingClientRect().width
$html.style.fontSize = pageWidth / 16 + 'px'  //不一定是除以16,除以多少你自己喜欢
上一篇 下一篇

猜你喜欢

热点阅读