我正在尝试在div中设置一个图像,该图像将在5秒内缓慢出现(不透明度从0到1).我有这个代码:
.fadeDivIn {
opacity: 1;
transition: opacity 5s ease-in;
-moz-transition: opacity 5s ease-in;
-webkit-transition: opacity 5s ease-in;
-o-transition: opacity 5s ease-in;
}
Run Code Online (Sandbox Code Playgroud)
但我无法弄清楚如何自动触发它.
我一直在使用CSS3关键帧转换到其他元素,理想情况下应用类似于不透明度的东西,但是已经碰到了一堵砖墙.有人可以帮忙吗?
http://jsfiddle.net/DerekL/9PfMF/
div{
-webkit-animation: fadein 5s linear 1 normal forwards;
}
@-webkit-keyframes fadein{
from { opacity: 0; }
to { opacity: 1; }
}
Run Code Online (Sandbox Code Playgroud)
看下面的例子,您需要使用关键帧
div {
background: #333;
width: 200px;
height: 200px;
-webkit-animation: smooth 5s ease-in;
-moz-animation: smooth 5s ease-in;
-o-animation: smooth 5s ease-in;
-ms-animation: smooth 5s ease-in;
animation: smooth 5s ease-in;
}
@-webkit-keyframes smooth {
0% { opacity: 0;}
100% { opacity: 1;}
}
Run Code Online (Sandbox Code Playgroud)
范例:http://jsfiddle.net/zxx8u/1/