How do high-DPI devices like Retina displays and 1080p phones handle pixels in media queries?

会有一股神秘感。 提交于 2021-02-05 08:15:07

问题


For example, how many pixels does the iPhone with a Retina display appear to a media query? Is it 320 pixels or 640 pixels? If it's 640 pixels, how can a website deal with different device resolutions? Is there any way to use units that are the same regardless of a screen's resolution?


回答1:


Retina devices like the iPhone and iPad usually use 2 device pixels = 1 CSS pixel. So a media query like this:

@media all and (max-width: 320px) {
}

actually will target an iPhone (portrait), even though it is 640 device pixels wide.



来源:https://stackoverflow.com/questions/23439307/how-do-high-dpi-devices-like-retina-displays-and-1080p-phones-handle-pixels-in-m

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