简体   繁体   English

如何在 macbook 上检测设备的屏幕分辨率?

[英]How to detect device's screen resolution on macbook?

It's said that to calculate screen real resolution I need to multiply screen.width by window.devicePixelRatio .据说要计算屏幕实际分辨率,我需要将screen.width乘以window.devicePixelRatio The thing is on one of my laptops it works perfectly fine, window.screen.width = 1280, multiplying by pixel ratio (2) = 2560, which is correct according to system information.这东西在我的一台笔记本电脑上工作得很好,window.screen.width = 1280,乘以像素比 (2) = 2560,根据系统信息这是正确的。

But on my second laptop screen.width = 1440px, and pixel ratio is 2, which gives 2880px in width, but in system information it's said my resolution is still 2560 x 1600.但是在我的第二台笔记本电脑上,screen.width = 1440px,像素比为 2,宽度为 2880px,但在系统信息中显示我的分辨率仍然是 2560 x 1600。

So how do I calculate screen's resolution in this case?那么在这种情况下如何计算屏幕的分辨率呢?

screen.width屏幕宽度

real resolution实际分辨率

PS: my second laptop is 13" macbook pro 2020 PS:我的第二台笔记本电脑是 13" macbook pro 2020

PPS: well, I realised it depends on my settings, and is there a way to know the device's resolution as my settings can vary? PPS:好吧,我意识到这取决于我的设置,有没有办法知道设备的分辨率,因为我的设置可能会有所不同?

well, after some research I realised, that there's no way to get physical characteristics of displays, and device pixel ratio won't show the real css-to-physical pixels ratio好吧,经过一些研究我意识到,没有办法获得显示器的物理特性,并且设备像素比率不会显示真实的 css 与物理像素比率

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM