html - CSS3 动画并保持结束位置

标签 html css

<分区>

我创建了一个动画,可以在下面的 FIDDLE 中看到.为了创建动画,我使用了以下 CSS 代码和 HTML 代码:

HTML

<div>
  <h2>
    Welcome
    <span>:)</span>
  </h2>
 </div>

CSS

*{
  font-size:28px;
  margin:20px;
}
div span{
    -webkit-animation-name: spin;
    -webkit-animation-duration: 1000ms;
    -webkit-animation-iteration-count: 1;
    -webkit-animation-timing-function: ease-in-out;
    -moz-animation-name: spin;
    -moz-animation-duration: 1000ms;
    -moz-animation-iteration-count: 1;
    -moz-animation-timing-function: ease-in-out;
    -ms-animation-name: spin;
    -ms-animation-duration: 1000ms;
    -ms-animation-iteration-count: 1;
    -ms-animation-timing-function: ease-in-out;

    animation-name: spin;
    animation-duration: 1000ms;
    animation-iteration-count: 1;
    animation-timing-function: ease-in-out;    
    display:inline-block;
}
@-ms-keyframes spin {
    from { -ms-transform: rotate(0deg); }
    to { -ms-transform: rotate(360deg); }
}
@-moz-keyframes spin {
    from { -moz-transform: rotate(0deg); }
    to { -moz-transform: rotate(360deg); }
}
@-webkit-keyframes spin {
    from { -webkit-transform: rotate(0deg); }
    to { -webkit-transform: rotate(360deg); }
}
@keyframes spin {
    from {
        transform:rotate(0deg);
    }
    to {
        transform:rotate(90deg);
    }
}

从演示中可以看出,我旋转了笑脸。我想要实现的是笑脸保持在最后一个位置。有谁知道我如何在不使用 Javascript 的情况下解决这个问题?

最佳答案

添加这个:

animation-fill-mode: forwards; 

关于html - CSS3 动画并保持结束位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39122447/

上一篇:html - 移动菜单 Bootstrap 中的 Logo

下一篇:css - 如何阻止高 :auto in CSS? 溢出

相关文章:

css - 在 svg 中的样式标签上添加多个谷歌字体

HTML 下拉菜单不起作用

html - 如果存在其他 div,则 div 的 CSS 宽度

html - 在中间对齐一个 div 不起作用

HTML 选择框 : combining background image with background color in IE

javascript - 通过列表中的按键触发点击

css - SASS SCSS函数生成具有动态路径的类

javascript - 单击 "page jump"链接时部分网站消失

javascript - bootstrap模态点击div出现一次

javascript - 如何根据内容将页脚固定在特定高度,如果内容增加它会变大