在Firefox上一切正常,但chrome顯示動畫文本模糊。我所做的一切都像-webkit-font-smoothing: subpixel-antialiased;
,-webkit-transform: translate3d(0,0,0);
和之前的一切這裏提到:Chrome動畫使文本模糊
Webkit-based blurry/distorted text post-animation via translate3d
但問題依然存在。
我做了一個非常簡單的例子來向你展示它的外觀。我該如何解決這個問題?
var text = 1;
function next() {
var next = (text == 2) ? 1 : 2;
document.getElementById('text' + text).className = 'out';
document.getElementById('text' + next).className = 'in';
text = next;
}
body {
padding: 0;
margin: 0;
font-family: tahoma;
font-size: 8pt;
color: black;
}
div {
height: 30px;
width: 100%;
position: relative;
overflow: hidden;
margin-bottom: 10px;
}
div div {
opacity: 0;
position: absolute;
top: 0;
bottom: 0;
right: 0;
left: 0;
}
.in {
-webkit-animation: comein 1s 1;
-moz-animation: comein 1s 1;
animation: comein 1s 1;
animation-fill-mode: both;
}
@keyframes comein {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
.out {
-webkit-animation: goout 1s 1;
-moz-animation: goout 1s 1;
animation: goout 1s 1;
animation-fill-mode: both;
}
@keyframes goout {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
<div>
<div class="in" id="text1">Hello! I'm Test Text. I'm Test Text jr Father!</div>
<div id="text2">Hi, I'm test text jr. I'm sharp and beautiful by nature but when I came in, Chrome made me blurry and I'm bad, I'm bad! ... Who's bad :)</div>
</div>
<button onclick="next();">Next</button>
你也可以看到在CodePen
無法在Chrome V53重現//的jsfiddle。 net/1x8azozx/ – nkmol
@nkmol你可以用codepen試一下:http://codepen.io/anon/pen/kkpJaL – ICE
我在使用OSX的chrome上沒有模糊在這裏FYI –