freeCodeCamp/curriculum/challenges/chinese/01-responsive-web-design/applied-visual-design/animate-elements-continuall...

1.8 KiB
Raw Blame History

id title challengeType videoUrl localeTitle
587d78a8367417b2b2512ae3 Animate Elements Continually Using an Infinite Animation Count 0 动画元素不断使用无限动画计数

Description

之前的挑战涉及如何使用某些动画属性和@keyframes规则。另一个动画属性是animation-iteration-count ,它允许您控制循环动画的次数。这是一个例子: animation-iteration-count: 3;在这种情况下动画将在运行3次后停止但可以通过将该值设置为无限来使动画连续运行。

Instructions

要使球在连续循环中保持在右侧弹跳,请将animation-iteration-count属性更改为无限。

Tests

tests:
  - text: <code>animation-iteration-count</code>属性应具有无限值。
    testString: 'assert($("#ball").css("animation-iteration-count") == "infinite", "The <code>animation-iteration-count</code> property should have a value of infinite.");'

Challenge Seed

<style>

  #ball {
    width: 100px;
    height: 100px;
    margin: 50px auto;
    position: relative;
    border-radius: 50%;
    background: linear-gradient(
      35deg,
      #ccffff,
      #ffcccc
    );
    animation-name: bounce;
    animation-duration: 1s;
    animation-iteration-count: 3;
  }

  @keyframes bounce{
    0% {
      top: 0px;
    }
    50% {
      top: 249px;
      width: 130px;
      height: 70px;
    }
    100% {
      top: 0px;
    }
  }
</style>
<div id="ball"></div>

Solution

// solution required