CSS3动画填充模式属性

时间:2015-05-28 21:59:41

标签: html css3 animation css-transitions

我创建了一种效果,其中文本滑入窗口并在动画结束后停留在那里。我已经能够让动画处理1个文本,但由于某种原因,第2个部分无效。

请看我的小提琴https://jsfiddle.net/9fpryou8/

提前致谢。

figure h2.world {
  position: absolute;
  top: 20%;
  left: 61%;
  background-color: transparent;
  font-size: 7em;
  color: white;
  font-family: Paytone One, Verdana, sans-serif;
  transform: translateX(300%);
  text-shadow: 0px 0px 50px black;

  -moz-animation-name: slideWorld;
  -moz-animation-iteration-count: 1;
  -moz-animation-timing-function: ease-in;
  -moz-animation-duration: 0.4s;
  -moz-animation-delay: 1.4s;
  -moz-animation-fill-mode: forwards;

  -webkit-animation-name: slideWorld;
  -webkit-animation-iteration-count: 1;
  -webkit-animation-timing-function: ease-in;
  -webkit-animation-duration: 0.4s;
  -webkit-animation-delay: 1.4s;
  -webkit-animation-fill-mode: forwards;

  animation-name: slideWorld;
  animation-iteration-count: 1.4;
  animation-timing-function: ease-in;
  animation-duration: 0.4s;
  animation-delay: 1.4s;
  animation-fill-mode: forwards;
}

2 个答案:

答案 0 :(得分:1)

.world中,替换

animation-iteration-count: 1.4;

animation-iteration-count: 1;



figure {
    height: 98vh;
    background-color: grey;
}
figure h2.hello {
  position: absolute;
  top: 20%;
  left: 39%;
  font-size: 1em;
  background-color: transparent;
  color: white;
  font-family: Paytone One, Verdana, sans-serif;
  transform: translateX(-400%);
  text-shadow: 0px 0px 50px black;
  
  -moz-animation-name: slideHello;
  -moz-animation-iteration-count: 1;
  -moz-animation-timing-function: ease-in;
  -moz-animation-duration: 0.4s;
  -moz-animation-delay: 1s;
  -moz-animation-fill-mode: forwards;

  -webkit-animation-name: slideHello;
  -webkit-animation-iteration-count: 1;
  -webkit-animation-timing-function: ease-in;
  -webkit-animation-duration: 0.4s;
  -webkit-animation-delay: 1s;
  -webkit-animation-fill-mode: forwards;

  animation-name: slideHello;
  animation-iteration-count: 1;
  animation-timing-function: ease-in;
  animation-duration: 0.4s;
  animation-delay: 1s;
  animation-fill-mode: forwards;
}

figure h2.world {
  position: absolute;
  top: 20%;
  left: 61%;
  background-color: transparent;
  font-size: 1em;
  color: white;
  font-family: Paytone One, Verdana, sans-serif;
  transform: translateX(300%);
  text-shadow: 0px 0px 50px black;
  
  -moz-animation-name: slideWorld;
  -moz-animation-iteration-count: 1;
  -moz-animation-timing-function: ease-in;
  -moz-animation-duration: 0.4s;
  -moz-animation-delay: 1.4s;
  -moz-animation-fill-mode: forwards;

  -webkit-animation-name: slideWorld;
  -webkit-animation-iteration-count: 1;
  -webkit-animation-timing-function: ease-in;
  -webkit-animation-duration: 0.4s;
  -webkit-animation-delay: 1.4s;
  -webkit-animation-fill-mode: forwards;

  animation-name: slideWorld;
  animation-iteration-count: 1;
  animation-timing-function: ease-in;
  animation-duration: 0.4s;
  animation-delay: 1.4s;
  animation-fill-mode: forwards;
}

/**** Display Hello on Load ****/
@-moz-keyframes slideHello {
  to {
    -moz-transform: translateX(-39%);
  }
}
@-webkit-keyframes slideHello {
  to {
    -webkit-transform: translateX(-39%);
  }
}
@keyframes slideHello {
  to {
   transform: translateX(-39%);
  }
}

/**** Display World on Load ****/
@-moz-keyframes slideWorld {
  to {
    -moz-transform: translateX(-61%);
  }
}
@-webkit-keyframes slideWorld {
  to {
    -webkit-transform: translateX(-61%);
  }
}
@keyframes slideWorld {
  to {
   transform: translateX(-61%);
  }
}

<figure>
  <h2 class="hello">Hello</h2>
  <h2 class="world">World</h2>
</figure
&#13;
&#13;
&#13;

或者简单地删除它:animation-iteration-count的初始值为1

答案 1 :(得分:0)

你输入错误

animation-iteration-count: 1.4;更改为animation-iteration-count: 1;

然后它应该工作