1
我是一个CSS3动画的新手,但我看到处处都是,我找不到解决这个问题的方法。我有一个JSP页面,我希望背景从绿色慢慢淡化为蓝色,然后以相反的方式慢慢淡出,并无限重复此过程。如何无限地在两种颜色动画之间切换?
我现在已经从绿色变成了蓝色,但是之后它立刻变回蓝色。有没有办法播放两个动画,从绿色到蓝色,然后是蓝色到绿色,然后无限重复?
这里的CSS代码我现在有:
@keyframes changeColorGreenToBlue {
from { background-color: rgb(146,213,142);}
to {background-color: rgb(133,184,222);}
}
@keyframes changeColorBlueToGreen {
from {background-color: rgb(133,184,222);}
to { background-color: rgb(146,213,142);}
}
.jumbotron {
height: 100%;
width: 100%;
background-color: green;
animation: changeColorGreenToBlue ease;
animation-iteration-count: infinite;
animation-duration: 4s;
animation-fill-mode: both;
animation-name: changeColorBlueToGreen;
animation-iteration-count: infinite;
animation-duration: 4s;
background-size: cover;
background-repeat: repeat-y;
margin-bottom:1px;
}
这是一个有点乱,因为我只是想一切得到它的工作。对于那个很抱歉!
顺便说一句,在这里你不需要'animation-fill-mode'。 – TylerH
@TylerH我只是简单地将Tim的动画代码复制为一个快速和肮脏的解决方案,但谢谢指出。 – medievalgeek
啊,我没有注意到。只是以为你写了一切! – TylerH