我正在尝试创建一个 Flink 的元素动画,它应该持续一秒半,它有红色边框和绿色背景,还有半秒绿色边框和红色背景,颜色的变化应该是即时的。
我是这样试的:
0, 49%, 99%, 100% {
background-color: rgb(117,209,63);
border: 3px solid #e50000;
}
49%, 50%, 99% {
background-color: #e50000;
border: 3px solid rgb(117,209,63);
}
它有点工作,但颜色过渡非常缓慢。我也尝试了这个:
0%, 49% {
background-color: rgb(117,209,63);
border: 3px solid #e50000;
}
49%, 50% {
background-color: #e50000;
border: 3px solid rgb(117,209,63);
}
50%, 99% {
background-color: #e50000;
border: 3px solid rgb(117,209,63);
}
99%, 100% {
background-color: rgb(117,209,63);
border: 3px solid #e50000;
}
还有这个
0%, 50% {
background-color: rgb(117,209,63);
border: 3px solid #e50000;
}
50%, 99% {
background-color: #e50000;
border: 3px solid rgb(117,209,63);
}
但是没有任何东西像预期的那样工作...有什么帮助吗,拜托?
3条答案
按热度按时间gtlvzcf81#
看一下这个。This fiddle应该非常准确:
omtl5h9j2#
很难猜出你想要的行为是什么,但有几点值得注意:
animation-direction: alternate;
。animation-timing-function:
step-end
(或steps(1,end);
,但必须将"目标"状态移动到"中间"关键帧)。cubic-bezier(.8,0,.2,1)
或1,0,0,1
--在短时间内,它与离散状态几乎没有区别。vkc1a9a23#
对前一位朋友已经提供的代码进行优化