首页htmlkeyframeAnimation - 如何创建基于关键帧的颜色动画

Animation - 如何创建基于关键帧的颜色动画

我们想知道如何创建基于关键帧的颜色动画。

<!DOCTYPE html>
<html>
<style>
div {
  width: 100px;
  height: 100px;
  background: red;
  animation: myfirst 5s;
  -moz-animation: myfirst 5s; /* Firefox */
  -webkit-animation: myfirst 5s; /* Safari and Chrome */
  -o-animation: myfirst 5s; /* Opera */
}

@keyframes myfirst {
  from {background: red;}
    to {background: yellow;}
}
@-moz-keyframes myfirst /* Firefox */ {
  from {background: red;}
    to {background: yellow;}
}
@-webkit-keyframes myfirst /* Safari and Chrome */ {
  from {background: red;}
    to {background: yellow;}
}
@-o-keyframes myfirst /* Opera */ {
  from {background: red;}
    to {background: yellow;}
}
</style>
</head>
<body>
  <div></div>
</body>
</html>
</body>
</html>