Reputation: 217
I was having trouble with transform: translate(-50%, -50%) in combination with a google font in chrome. This combination made the text look blurry. I noticed it was caused by the translate and after looking at the position of the element, I noticed it was positioned on half a pixel. I was able to fix it with translate(calc(-50% - 0.5px), -50%), but rather have a better solution than this workaround.
Is there perhaps a way to round the pixels to a whole number when using percentages?
Upvotes: 3
Views: 1728
Reputation: 3968
Since May 2024 we can use round()
transform: translate(round(down,calc(-50%),1px), round(down,calc(-50%),1px))
Meanwhile, CSS.supports()
can be used to check the whether the round
operator is supported.
Upvotes: 0
Reputation: 454
You could try setting transform-style: preserve-3d
on the parent or maybe modify your transform property to also include perspective(1px)
.
Upvotes: 1