3

I just noticed that my screen resolution is not right detected. If I use THIS and THIS I get a resolution of 1280 x 720. But if I look in my Windows options I have a resolution of 1920 x 1080.

So I set my resolution (in Windows) to 800 x 600 and checked it again in the links above. Now both are showing 800 x 600 too.

My questions:
Why is my higher resolution not detected by js/css?

I made a little "table" with the different resoutions (right windows/ left js,css):

enter image description here

It looks like the proportion between both values are the same for every pair.

EDIT: Thanks to Schlaus, I tried it with different queries und colors. And css is also detecting just up to 1280 x 720 and not higher.

Community
  • 1
  • 1
theoretisch
  • 1,718
  • 5
  • 24
  • 34
  • Check that your browser's zoom level is 100%. – Schlaus Feb 01 '17 at 13:29
  • 1
    Also, this would be ridiculously easy to test. Just make a page with a media query, that changes the background of page to red if the width is below a threshold, and blue otherwise (pick colors to your liking). – Schlaus Feb 01 '17 at 13:34
  • The zoom lvl doesn't affect the displayed resolution in js. I just tried it. But the zoom is at 100%. – theoretisch Feb 01 '17 at 13:34
  • Is it just the 1920x1080 that displays incorrectly or if you select other resolutions above 1280 x 720 do you get similar issues? – RobPethi Feb 01 '17 at 13:35
  • All resolutions above are displayed wrong. – theoretisch Feb 01 '17 at 13:37

1 Answers1

1

The problem was the scaling in Windows 10. It was set to 150%. After changing it to 100% everything was displayed correctly.

On desktop -> right click -> display settings

theoretisch
  • 1,718
  • 5
  • 24
  • 34
  • Is there a way to get the scaling value itself? I don't know which API (maybe Win32) I should use for this. – Trung0246 Jul 11 '20 at 20:47
  • I havent tried it but this seem the way to go. https://learn.microsoft.com/en-us/windows/win32/api/shellscalingapi/nf-shellscalingapi-getscalefactorfordevice – theoretisch Jul 12 '20 at 21:16