EDIT 2016-07-04(Since this question is getting popular): This is a bug in Chrome. Developers are actively working on a fix.
EDIT 2017-05-14 The bug seems to be fixed, the fix will be introduced in Chrome 60
EDIT 2018-05-04 A fix has been merged, but the bug still appears to be present.
So I have this very ugly-looking window that is centered on the screen by this CSS:
.popup
{
position: fixed;
top: 0;
bottom: 0;
transform: translate(-50%, -50%);
}
However, it looks like this on Chrome (the font looks really blurry):
But like this on Firefox:
When I remove the transform
rule, the text looks nice and crispy again, but then it's no longer correctly centered.
When I go to chrome://flags
and execute #disable-direct-write
it looks nicer, but users are obviously not going to do that and it doesn't solve the problem.
How can I make my font look nice while still having the window centered?
My chrome version is 44.0.2403.155
I have a three.js
demo using WebGL that renders on a background canvas. When I disable the demo, the problem no longer occurs.
JSFiddle with the background.
JSFiddle without the background.
Many users have been reporting that sometimes Chrome looks blurry. To fix that, you just need to clear your cache and browsing data. Resetting the browser settings to default can also help with these types of issues.
Blurry font problems can be caused by cables that aren't connected properly, older monitors, and poor screen resolution settings.
A suggestion from a related discussion solved the issue for me: https://stackoverflow.com/a/46117022/7375996
Using calc with some offset solved the issue in my case:
transform: translate(calc(-50% + 0.5px), calc(-50% + 0.5px));
I've tried different solutions in different, sometimes scary, combinations:
translate3d
instead of translateY
zoom:2; transform: scale(0.5);
or zoom:0.5; transform: scale(2);
transform: translate(calc(-50% + 0.5px), calc(-50% + 0.5px));
-webkit-filter: blur(0);
perspective: 1000px
scale(1.0, 1.0)
-webkit-font-smoothing: subpixel-antialiased;
none of them work in july 2019.
The only solution i found for modals, that should be centered - to use a flexbox aligment instead of transform: translate.
.modal__container {
display: flex;
justify-content: center;
align-items: center;
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0, 0, 0, 0.5);
}
.modal {
box-sizing: border-box;
max-width: 80%;
max-height: 80%;
padding: 20px;
overflow-y: auto;
background: #fff;
}
<div class="modal__container">
<div class="modal">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
</div>
Problem in half of pixel.
Try: transform: translate(-50%, -51%);
It will work!
I found out -webkit-filter: blur(0)
could fix your blurry font in Chrome on Windows:
JSFiddle
#projectPopup {
...
-webkit-filter: blur(0);
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
Use a normalization of the transform after your animation:
Transform X/Y normalization
Or We scale the texture with zoom double, then scale down again. In some cases this cannot be applied due to other complex transformations or translations, and is not perfect.
...{
zoom:2;
-webkit-transform: scale(0.5);
transform: scale(0.5);
}
The height of the elements must be even numbers https://prnt.sc/mtxxa2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With