GithubHelp home page GithubHelp logo

有两个疑问,求大神解答,为啥要分成10a,1rem=75有啥用,还有为啥把安卓置成dpr1,安卓那么多2和3的 about lib-flexible HOT 7 CLOSED

rpig avatar rpig commented on August 28, 2024
有两个疑问,求大神解答,为啥要分成10a,1rem=75有啥用,还有为啥把安卓置成dpr1,安卓那么多2和3的

from lib-flexible.

Comments (7)

airen avatar airen commented on August 28, 2024 6

简单的做一下回答。

这个方案是根据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.

iceshu avatar iceshu commented on August 28, 2024

淘宝的做法是只管iOS,安卓一律把dpr设为1,官方的说法是安卓的厂商会自己修改dpr,导致安卓上的 window. devicePixelRatio 是假的。

from lib-flexible.

iceshu avatar iceshu commented on August 28, 2024

如果分成一百分 一份为a 1rem为7.5a 那么ip6 布局视口是750 1rem为7.5 60px转换就是8rem 600px转换就是80rem 我觉得没啥 就是自己这样定义而已

from lib-flexible.

hbrls avatar hbrls commented on August 28, 2024

我的理解就是保持比例缩放,大屏幕看到的更大,小屏幕看到的更小

from lib-flexible.

rpig avatar rpig commented on August 28, 2024

@iceshu 那安卓为啥默认不设成2

from lib-flexible.

jasonChen1982 avatar jasonChen1982 commented on August 28, 2024

其实感觉分成10分这个概念没那么必要。说白了rem只是一个比例中转的作用,当打开页面时js根据此时屏幕的尺寸动态算出当前屏幕的与设计稿之间的比值,然后将比值作用到根font-size上,这样页面里的所有rem单位的内容就随之放大或缩小。

from lib-flexible.

rpig avatar rpig commented on August 28, 2024

@airen 谢大神

from lib-flexible.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.