Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS, height makes the border color change

Sometimes CSS acts weird in chrome, the difference between the two divs are only the height parameter, but as a result: the border color is different.

body {
background: black;
}

#div1 {
    border: 1px solid white;
    height: 41px;
    width: 100px;
    transform: rotateZ(270deg);
    transform-origin: right;
}

#div2 {
    border: 1px solid white;
    height: 40px;
    width: 100px;
    transform: rotateZ(270deg);
    transform-origin: right;
}
<div id="div1">

</div>

<br><br><br><br><br><br>

<div id="div2">

</div>

PS : I am working under chrome with 100% zoom

result : picture

like image 257
Mehdi Souregi Avatar asked Nov 06 '22 23:11

Mehdi Souregi


1 Answers

This is in fact an anti aliasing issue. The 1px border is in between two pixels, resulting in this grey looking color.

To visualize this I have taken a screenshot for you, zoomed in and put a grid over it:

enter image description here

Keep that in mind when transforming objects.

like image 135
Cr45hCode Avatar answered Nov 15 '22 07:11

Cr45hCode