如何在动画后保留样式?

ame*_*_me 29 html css css3 css-animations

我正在投资组合,以显示我申请下一份学习的时间.自从我们生活在2012年以来,它拥有大量精美的动画和CSS3垃圾,只是为了给他们"我们需要这个家伙"的感觉.我现在有点问题.

这只是特定元素的一小部分:

/* This is the CSS of the elements with the id called 'fadein' */
#fadein {
    -moz-animation-duration: 2s;
    -moz-animation-name: item;
    -moz-animation-delay: 4.5s;
    -webkit-animation-duration: 5s;
    -webkit-animation-name: item;
-webkit-animation-delay: 4.5s;
opacity:0;
-webkit-opacity:0;
}

@-webkit-keyframes item {
from {
-webkit-opacity: 0;
     }
to { 
-webkit-opacity: 1;
 }
}
Run Code Online (Sandbox Code Playgroud)

请注意,我省略了Firefox关键帧,因为它们完全相同.对,丑陋格式的CSS,使得id为'fadein'的元素...淡入.

问题是,动画结束后元素会再次消失.这将丑陋格式的Css变成无法使用的Css.

有没有人知道如何在动画后保留更改的样式?

我想之前已经问过这个问题,如果是这样的话,我很抱歉.

met*_*ion 58

试试:

#fadein {
  -webkit-animation-fill-mode: forwards; /* Chrome 16+, Safari 4+ */
  -moz-animation-fill-mode: forwards;    /* FF 5+ */
  -o-animation-fill-mode: forwards;      /* Not implemented yet */
  -ms-animation-fill-mode: forwards;     /* IE 10+ */
  animation-fill-mode: forwards;         /* When the spec is finished */
}
Run Code Online (Sandbox Code Playgroud)