gpt4 book ai didi

CSS3 关键帧动画不起作用

转载 作者:太空宇宙 更新时间:2023-11-04 03:21:04 24 4
gpt4 key购买 nike

我正在使用 css3 从左到右为 Sprite 制作动画,使用关键帧动画。有人帮忙吗?如何解决这个问题?

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<style>
#adam{
background:url(adam.png);
width: 120px;
height: 180px;
animation: walk-east 1.0s steps(8) infinite;
}
@keyframes walk-east {
from { background-position: 0px; }
to { background-position: -960px; }
}
</style>
<body>

<div id="adam"></div>


<body>
</html>

https://www.adamkhoury.com/demo/sprite_sheets/adam.png

最佳答案

您缺少 -webkit- 前缀。

Browser compatibility table for @keyframes .

#adam {
background: url(https://www.adamkhoury.com/demo/sprite_sheets/adam.png);
width: 120px;
height: 180px;
-webkit-animation: walk-east 1.0s steps(8) infinite;
animation: walk-east 1.0s steps(8) infinite;
}
@-webkit-keyframes walk-east {
from {
background-position: 0px;
}
to {
background-position: -960px;
}
}
@keyframes walk-east {
from {
background-position: 0px;
}
to {
background-position: -960px;
}
}
<div id="adam"></div>

关于CSS3 关键帧动画不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27888664/

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