The width in css is defined as 100px, but what is actually displayed is 150px?

-sharpelem {
    width:100px;
    height: 100px;
    border:1px solid;
}

<div id="elem"></div>

as shown above, it is only simple to set the width and height, but in fact, when the web page is displayed, when you take a screenshot with qq screenshot software, you find that its width and height are more than 150. why?

I am using a chrome browser, and the browser is not zoomed in. Can anyone help me test it?

Css
Aug.27,2021

it is possible that your win10 system has used 125% zoom, and it will be normal if you change it back to 100%.


check whether your browser is enlarged.


Baidu knows the answer:
px units are based on the resolution of the screen, but if the browser uses the zoom function, the display effect will not match the actual pixels. In addition, mobile browsers use the "viewport" (viewport) as the screen benchmark (otherwise, due to the large size of the phone screen, the same web page will behave differently on different phones based on the physical size), which will also cause the px to be inconsistent with the actual pixels.

< H1 > CSS pixels, physical pixels, logical pixels, device pixel ratio, PPI, Viewport < / H1 >

https://github.com/jawil/blog.


Ctrl+Shift+C move the mouse to the element to see if it is 15000150


use the console to see what the actual width and height is

clipboard.png


the zoom of each browser is different. 100% of Edge is larger than Chrome. It is correct to use developer tools to see 100PX.


should be viewed on the console. Screenshot software is not accurate.

Menu