html keep same character size in all devices

只谈情不闲聊 提交于 2019-12-02 09:41:46

Thank you all. I have learned a lot. But I find the reason myself.
The browser on mobile device will auto scale the page to adapt the mobile screen. I just add this line to the html and it works:

<meta name="viewport" content="width=device-width, initial-scale=1.0"/>

You may use something like @media handheld and (max-width: 500px). But unfortunately, I don't think there's a way to use CSS like

fontSize * (width per pixel of my laptop)/(width per pixel of that device)

There is only one way so far that we know, you need to do some thing like this

@media (max-width: 300px) {
    html { font-size: 70%; }
}

@media (min-width: 500px) {
    html { font-size: 80%; }
}

@media (min-width: 700px) {
    html { font-size: 120%; }
}

@media (min-width: 1200px) {
    html { font-size: 200%; }
}

Well ther is one thing you can do, You probably want to set your font sizes in pt units (1pt = 1/72 inch), which are resolution-independent and designed to look the same apparent size in any resolution.

Try adding the below code

body{
    -webkit-text-size-adjust: none;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!