我想从右向左移动图像,图像应该从屏幕的右侧进入并从屏幕的左侧退出,为此我写了这个CSS的动画代码,但它不工作,请帮助。从右向左移动图像 - 动画不能正常工作
.css文件
.imageAnimation {
position: 100% 0px;
-webkit-animation: moveToLeft 10s linear infinite;
animation: moveToLeft 10s linear infinite;
}
@-webkit-keyframes moveToLeft {
from {position: 100% 0px;}
to {position: 0% 0px;}
}
@keyframes moveToLeft {
from {position: 100% 0px;}
to {position: 0% 0px;}
}
.HTML文件
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<link rel="stylesheet" type="text/css" href="animation.css"/>
</head>
<body>
<img class="imageAnimation" style="position:absolute; top:0px; left:100%;" src="enemy.png" width="300" height="100"/>
</body>
</html>
你有codepen或jsfiddle的例子吗? – FlipFloop