Comments (7)
简单的做一下回答。
这个方案是根据vw的单位原理为基础理论。根据vw的单位原理,整个viewport是100vw,那么1a就等于1vw。假设我们的设计图是750px的宽度,那么1a就是7.5px。同时为了让font-size更适合阅读,就考虑在此基础上放大10倍,即10a=100vw,如此10a=75px。这样就把整个设计分成了10等份,每一等份就是75px,同时将html的font-size设成75px。然后根据不同的dpr来修改html元素的font-size值。
第二个问题,由于早期安卓的dpr属性不标准,所以强制设置为1。根据现在的技术成熟角度而言,可以考虑给安卓提供一份白名单。后期会根据这个给安卓做一些处理。
不知道这样的解释是否能帮您。
from lib-flexible.
淘宝的做法是只管iOS,安卓一律把dpr设为1,官方的说法是安卓的厂商会自己修改dpr,导致安卓上的 window. devicePixelRatio 是假的。
from lib-flexible.
如果分成一百分 一份为a 1rem为7.5a 那么ip6 布局视口是750 1rem为7.5 60px转换就是8rem 600px转换就是80rem 我觉得没啥 就是自己这样定义而已
from lib-flexible.
我的理解就是保持比例缩放,大屏幕看到的更大,小屏幕看到的更小
from lib-flexible.
@iceshu 那安卓为啥默认不设成2
from lib-flexible.
其实感觉分成10分这个概念没那么必要。说白了rem只是一个比例中转的作用,当打开页面时js根据此时屏幕的尺寸动态算出当前屏幕的与设计稿之间的比值,然后将比值作用到根font-size上,这样页面里的所有rem单位的内容就随之放大或缩小。
from lib-flexible.
@airen 谢大神
from lib-flexible.
Related Issues (20)
- 为啥不兼容pc 端自适应 HOT 1
- html的font-size最大为54 HOT 1
- 你网站不能访问了 HOT 4
- 你网站坏了
- vue开发我想pc端不用你这个布局而移动端用怎么办? HOT 2
- 540px HOT 3
- 反馈一个viewport方案不兼容的机型
- 页面在iframe中展示时rem设置的bug
- 强烈建议把推荐那篇vue的适配文章去掉. 不要给www.w3cplus.com导流!!! HOT 2
- px
- px转换rem,多位小数,div出现白边
- 既然已经设置为理想视口,setBodyFontSize里为什么还要根据dpr设置字体大小 HOT 15
- 如何针对微信浏览器的调整字体大小功能进行适配? HOT 5
- 可以设置html最小的字体值么?
- ios输入框键盘弹窗后界面变形 HOT 1
- 没使用说明吗? HOT 2
- 字体不响应怎么解决 HOT 3
- 大佬 你的组件库 pc 端 兼容一下吧 要不还得改源码 不方便维护啊 HOT 5
- help
- 安卓微信适配问题 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lib-flexible.