如何从 css 动画关键帧获取图像以在完成后保留在页面上
How to get an image from a css animation keyframe to remain on the page after complete
我只想iteration-count
运行一次,但之后,我希望我的图像无限期地保留在页面上。
有没有办法用 css 完成此操作,或者我需要应用 javascript 方法?
#contact-success-animation {
width: 100px;
height: 100px;
position: relative;
margin: auto auto;
-webkit-animation-name: success-animation; /* Chrome, Safari, Opera */
-webkit-animation-duration: 15s; /* Chrome, Safari, Opera */
-webkit-animation-iteration-count: 1; /* Chrome, Safari, Opera */
-webkit-animation-direction: normal; /* Chrome, Safari, Opera */
animation-name: success-animation;
animation-duration: 15s;
animation-iteration-count: 1;
animation-direction: normal;
}
/* Chrome, Safari, Opera */
@-webkit-keyframes success-animation {
0% {background-image: url(""); background-repeat: no-repeat;
background-size: 100% auto; height: 100px; width: 100px;}
33% {background-image: url(""); background-repeat: no-repeat;
background-size: 100% auto; height: 100px; width: 100px;}
66% {background-image: url(""); background-repeat: no-repeat;
background-size: 100% auto; height: 100px; width: 100px;}
100% {background-image: url("); background-repeat: no-repeat;
background-size: 100% auto; height: 100px; width: 100px;}
}
/* Standard syntax */
@keyframes success-animation {
0% {background-image: url(""); background-repeat: no-repeat;
background-size: 100% auto; height: 100px; width: 100px;}
33% {background-image: url(""); background-repeat: no-repeat;
background-size: 100% auto; height: 100px; width: 100px;}
66% {background-image: url(""); background-repeat: no-repeat;
background-size: 100% auto; height: 100px; width: 100px;}
100% {background-image: url(""); background-repeat: no-repeat;
background-size: 100% auto; height: 100px; width: 100px;}
}
<div id="contact-success-animation"></div>
animation-fill-mode: forwards;
此属性将在完成后保留 @ 关键帧中的最后一帧
你可以在这里找到更多信息 MDN
相关文章:
- 禁用滚动,但保留滚动条CSS
- 如何在javascript中进行CSS单元计算并保留CSS单元
- 应该很简单:当转到另一个页面时,如何在基本javascript/css/html页面上保留数据
- 使用 javascript 动态更改文本时保留 CSS
- 如何在不使用 CSS 的情况下在动态添加的 javascript DOM 元素中保留空格
- CSS:当 image1 动画不合适时,一组图像会移动,而它们应该保留在原处
- 如何从 css 动画关键帧获取图像以在完成后保留在页面上
- Javascript“对象”不保留css值
- 在悬停时保留和添加新的转换 (CSS/LESS)
- 在保留CSS的同时更改innerHTMl
- 当代码包含保留字时,设置代码的CSS
- 是否可以使用JavaScript转储DOM并保留CSS效果和布局
- 如何保留页面'阻止CSS影响加载html文档的iframe
- SVG到PNG保留CSS使用javascript
- Javascript代码Cookie保留/保留替代Css
- Jquery不保留CSS样式
- 将HTML加载到DIV中,但保留CSS,JS包括
- 对列表进行排序,但保留CSS标记
- 当Flash层放置在元素上时,保留CSS动画
- 用Javascript填充HTML表并保留CSS样式