我正在css中使用css中的animation-iteration-count属性来实现从左到右的动画,动画结束时如何删除或隐藏div,即一旦达到100%,应该从左到右与动画一起删除它。
与我们在图库应用中看到的图片相同
是否具有任何此类财产。
请我仅在CSS中需要解决方案。
下面是我的代码

<!DOCTYPE html>
<html>
<head>
<style>
div {
width: 100px;
height: 100px;
background: red;
position: relative;
-webkit-animation: mymove 1s;  /* Chrome, Safari, Opera */
-webkit-animation-iteration-count: 0;  /* Chrome, Safari, Opera */
animation: mymove 1s;
animation-iteration-count: 1;
}

/* Chrome, Safari, Opera */
@-webkit-keyframes mymove {
from {left: 0px;}
to {left: 100%;}
}
@keyframes mymove {
from {left: 0px;}
to {left: +100%;}
background: white;
}
</style>
</head>
<body>
<p><strong>Note:</strong> The animation-iteration-count property is not       supported in Internet Explorer 9 and earlier versions.</p>
<div></div>
</body>
</html>


提前致谢。

最佳答案

您正在寻找animation-fill-mode css属性。使用bothforwards作为值。


  animation-fill-mode属性指定元素的样式
  不播放动画时(完成时或播放动画时)
  延迟)。


更多信息here



jsFiddle



代码片段:



body {
  overflow: hidden;
  margin: 0;
}
div {
  width: 100px;
  height: 100px;
  background: red;
  position: relative;
  -webkit-animation: mymove 1s;
  /* Chrome, Safari, Opera */
  -webkit-animation-iteration-count: 0;
  /* Chrome, Safari, Opera */
  -webkit-animation-fill-mode: both;
  animation: mymove 1s;
  animation-iteration-count: 1;
  animation-fill-mode: both;
}
/* Chrome, Safari, Opera */

@-webkit-keyframes mymove {
  from {
    left: 0px;
  }
  to {
    left: 100%;
  }
}
@keyframes mymove {
  from {
    left: 0px;
  }
  to {
    left: 100%;
  }
}

<p><strong>Note:</strong> The animation-iteration-count property is not supported in Internet Explorer 9 and earlier versions.</p>
<div></div>

10-05 20:56
查看更多