1

When I select a device size in the Chrome Device Toolbar, the dimensions labelled on my HTML elements don't match. The device here is 600x600, but hovering the html element in DevTools shows 980x980. The box shadow shows that the element isn't overflowing. My zoom is at 100%. Why don't the numbers match?

enter image description here

<!DOCTYPE html>
<html lang="en">
    <head>
        <style>
            html,
            body {
                box-shadow: 0 0 0 10px red inset;

                margin: 0;
                padding: 0;

                width: 100vw;
                height: 100vh;
            }
        </style>
    </head>
    <body></body>
</html>
pyjamas
  • 4,608
  • 5
  • 38
  • 70

2 Answers2

1

I resolved this by setting the browser zoom to 100%

Vickel
  • 7,879
  • 6
  • 35
  • 56
Capucine
  • 21
  • 3
  • Yes I did figure this out. I just posted an answer with what I found – pyjamas Dec 19 '22 at 21:27
  • Nice to know what was your issue. Mine was pretty dumb ^^. When you initialize your project with a toolbox (like create react app) the environment is configured and the is the following: – Capucine Dec 21 '22 at 08:13
1

I resolved this by adding the following line inside <head>:

<meta name="viewport" content="width=device-width" />

The reason this happens is because using Chrome DevTools to simulate mobile device dimensions also simulates other aspects of a mobile device including a device pixel ratio of 2.0. The DPR value is locked to 2.0 in most device presets, and can be set manually with the Dimensions: Responsive option.

In the ... menu there is an option to toggle showing the DPR.

enter image description here

enter image description here

References:
https://developer.mozilla.org/en-US/docs/Web/HTML/Viewport_meta_tag https://stackoverflow.com/a/61410406/3620725

pyjamas
  • 4,608
  • 5
  • 38
  • 70