3
I noticed in a simple situation that elements with pixel are not always rendered as you imagine, a simple example is when one adjusts the browser zoom to more or less than 100%, making it appear that depending on the position and zoom one element of height equal to the other is a smaller pixel, an example is the very menu of the site Stackoverflow, example with zoom 175%:
You may notice that the last menu bar "looks" larger and the spacing of the first and second bar also looks larger.
Understand that this does not only occur in this 175% measure and it is not only with zoom, I tested in a colleague’s notebook with Windows10 and board GeForce® GTX 1050
(of course I understand that in part modern computers render with the "integrated card") and it uses in Windows settings for the entire operating system worth 125%:
When using this I realized in several places the same problem with zoom, the only displays that I noticed that the problem does not occur are those of retinal screens/screens and similar "technologies", this because they use a pixel density is higher.
But the question NAY is about monitors, screens and technologies of the market, the question is about how to avoid the problem in normal screens when the user adjusts something, as in the 125% example in Windows10, noting that this varies according to the resolution and even the monitor and is "unpredictable".
I tried to work with other units of measurement (em
, pt
, rem
, %
), but the problem persisted.
So there goes my question:
- How to avoid distortion of pixels in HTML elements in various screen/screen settings?
An example that problem occurs (if changing the display settings or the browser zoom):
*, ::after, ::before {
box-sizing: border-box;
}
body {
background-color: #007bff;
}
.v-navbar-toggle {
vertical-align: middle;
position: relative;
cursor: pointer;
display: inline-block;
background: none;
outline: 0;
border: none;
padding: 10px 8px;
color: #fff;
margin: 0;
}
.v-icon-bar {
background-color: currentColor;
overflow: hidden;
display: block;
width: 24px;
height: 2px;
border-radius: 1px;
}
.v-icon-bar+.v-icon-bar {
margin-top: 4px;
}
<button class="v-navbar-toggle">
<i class="v-icon-bar"></i>
<i class="v-icon-bar"></i>
<i class="v-icon-bar"></i>
</button>
Note: I also noticed that with SVG (depending on using) or icon-fonts this works a little better compared to html+css, but I am wanting to solve the problem of simple HTML elements.