css:
.flightNumber{
display: none;
-moz-transition: opacity 2000ms ease-in-out;
-o-transition: opacity 2000ms ease-in-out;
-webkit-transition: opacity 2000ms ease-in-out;
/*transition: opacity 2000ms ease-in-out;
opacity: 0;
}
.runIn{
-moz-transition: opacity 2000ms ease-in-out;
-o-transition: opacity 2000ms ease-in-out;
-webkit-transition: opacity 2000ms ease-in-out;
/*transition: opacity 2000ms ease-in-out;*/
opacity: 1;
display: block;
}
html code:<p class='flightNumber'></p>
js code:$(".flightNumber").addClass("runIn")
display:none If this is added, the animation cannot be effective, because display:none means that this element is not parsed on the page, and all styles of this element are invalid. Under this premise, transition: opacity 2000ms ease-in-out; is Invalid, so no animation effect is possible.
Thanks for the invitation.
The number
display
都去掉,另外前缀没必要写,直接原生就行。真有需要的话,可以先
.show()
下嘛(反正你opacity
is 0 and nothing can be seen).