如何确定CSS像素比率 [英] How are CSS pixel ratios determined

查看:174
本文介绍了如何确定CSS像素比率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

确定设备的css像素比率的因素究竟是什么。而且,作为一个奖励,是不同设备的不同分辨率下css像素的大小相同

What exactly are the factors that determine the css pixel ratio for a device. And, as a bonus, is the size of a css pixel the same across different devices of different resolutions

推荐答案

自己的尺寸和比率。 css像素考虑了比率(因此如果比率为2,则每个css像素中有4个像素)。用于找到每个css像素中的实际像素的数量的公式是比率^ 2。在iPhone 6+上,设备会报告更高的分辨率和比例,并对页面进行降采样以适应更小的1920x1080屏幕。

Each device reports its own dimensions and ratio. A css pixel takes into account the ratio (so if the ratio is 2, there are 4 pixels in each css pixel). The formula for finding the number of actual pixels in each css pixel is ratio^2. On the iPhone 6+, the device reports a higher resolution and ratio, and downsamples the page to fit the smaller 1920x1080 screen.

要回答问题的第二部分,在这些设备上没有像素密度和比率的约定,因此如果文本大小是静态的,文本可能在一部手机上看起来很大,而在另一部手机上看起来很小。由于这些原因,在开发移动设备时,通常可以在文字大小上使用vw或视口宽度单位。

To answer the second part of your question, there is no convention for pixel density and ratio on these devices, so if text size is static, text could look huge on one phone and tiny on another. For these reasons its usually good to use the "vw" or viewport-width unit on your text size when developing for mobile.

这是一个很好的链接,可用于查找各种手机的比率和设备宽度

这篇关于如何确定CSS像素比率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆