简体   繁体   English

设置CSS简易性,而不是缓和

[英]Setting CSS ease-in, not easing

Setting the text colour of an ID with CSS transitions isn't working. 使用CSS过渡设置ID的文本颜色不起作用。 It just changes it to red, but doesn't ease it. 它只是将其更改为红色,但并没有缓解它。

document.getElementById('colourword').innerHTML =
"<span id='flash' style='color: #000; transition: color 0.5s ease-in 0.5s; -moz-transition: color 0.5s ease-in 0.5s; -webkit-transition: color 0.5s ease-in 0.5s;'>X</span>";

var flash = document.getElementById('flash');
flash.style.color = "#dd0000";

If I type in the console document.getElementById('flash').color = "000"; 如果我在控制台中输入document.getElementById('flash').color = "000"; It will then fade black. 然后它将褪黑。

Any ideas? 有任何想法吗?

Its like a instant change on the color and it dosen't know what to change color from 就像颜色立即改变一样,它也不知道该如何改变颜色

This works for me: 这对我有用:

document.body.innerHTML =
"<span id='flash' style='color: #000; transition: color 0.5s ease-in 0.5s; -moz-transition: color 0.5s ease-in 0.5s; -webkit-transition: color 0.5s ease-in 0.5s;'>X</span>";

setTimeout(function() {
    var flash = document.getElementById('flash');
    flash.style.color = "#dd0000";
},0);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM