gpt4 book ai didi

css - 使用 CSS 的关键帧动画 - 在 Chrome 中不起作用

转载 作者:行者123 更新时间:2023-11-28 06:17:15 24 4
gpt4 key购买 nike

我创建了一个 jsfiddle使用我在 Chrome(版本 48.0.2564.116)中无法正常工作但在 IE(版本 11.0.9600.17631)中正常工作的代码。背景图像的动画在 IE 中运行良好,但在 Chrome 中没有出现动画。

在此先感谢您的帮助。

代码如下:

#backgroundOnly {
background-image: -webkit-linear-gradient(left, #CCC49F 0%, #ffffff 50%, #CCC49F 100%);
background-image: -ms-linear-gradient(left, #CCC49F 0%, #ffffff 50%, #CCC49F 100%); /* IE 10+ */
}

#backgroundAnimation {
width: 200px;
height: 100px;
background: red;
position :relative;
animation: spotLight 5s linear 0s infinite alternate;
-webkit-animation: spotLight 5s infinite alternate linear 0s ;
background-image: -webkit-linear-gradient(left, #CCC49F 0%, #ffffff 50%, #CCC49F 100%); Safari /*5.1+, Mobile Safari, Chrome10+ */
}

@keyframes spotLight { /* IE 10+ */
from {background-image: -ms-linear-gradient(left, #CCC49F 0%, #ffffff 75%, #CCC49F 100%);}
to {background-image: -ms-linear-gradient(left, #CCC49F 0%, #ffffff 20%, #CCC49F 100%);}
}

@-webkit-keyframes spotLight { /*Safari 5.1+, Mobile Safari, Chrome10+ */
from {background-image: -webkit-linear-gradient(left, #CCC49F 0%, #ffffff 75%, #CCC49F 100%);}
to {background-image: -webkit-linear-gradient(left, #CCC49F 0%, #ffffff 20%, #CCC49F 100%);}
}
<!DOCTYPE html>

<body>
<div id="backgroundOnly">
<p>background only</p>
<div id="backgroundAnimation">
<p>background animation</p>
</div>
</div>
</body>

最佳答案

https://jsfiddle.net/b4192ynm/1/

您的代码中有很多错别字和错误。

#backgroundOnly {
background-image: -webkit-linear-gradient(left, #ccc49f 0%, #ffffff 50%, #ccc49f 100%);
background-image: linear-gradient(to right, #ccc49f 0%, #ffffff 50%, #ccc49f 100%);
}

#backgroundAnimation {
width: 200px;
height: 100px;
background: red;
position: relative;
-webkit-animation: spotLight 2s linear 0s infinite alternate;
animation: spotLight 2s linear 0s infinite alternate;
}

@-webkit-keyframes spotLight {
from {
background-image: -webkit-linear-gradient(left, #ccc49f 0%, #ffffff 75%, #ccc49f 100%);
}
to {
background-image: -webkit-linear-gradient(left, #ccc49f 0%, #ffffff 20%, #ccc49f 100%);
}
}

@keyframes spotLight {
from {
background-image: linear-gradient(to right, #ccc49f 0%, #ffffff 75%, #ccc49f 100%);
}
to {
background-image: linear-gradient(to right, #ccc49f 0%, #ffffff 20%, #ccc49f 100%);
}
}

所以现在至少他们在 Chrome 中从一侧轻弹到另一侧。如果你的意思是他们没有很好地逐渐改变,那么这个问题是 this question. 的重复。如您所见,目前只有 IE 支持此功能。

关于css - 使用 CSS 的关键帧动画 - 在 Chrome 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35824979/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com