freeCodeCamp/curriculum/challenges/chinese/01-responsive-web-design/applied-visual-design/create-visual-direction-by-...

1.6 KiB
Raw Blame History

id title challengeType videoUrl localeTitle
587d78a7367417b2b2512ae2 Create Visual Direction by Fading an Element from Left to Right 0 通过从左到右淡化元素来创建视觉方向

Description

对于此挑战,您将更改动画元素的opacity ,使其在到达屏幕右侧时逐渐变淡。在显示的动画中,具有渐变背景的圆形元素按照@keyframes规则向右移动动画的50标记。

Instructions

使用id为ball定位元素,并将opacity属性设置为0.1 50% ,因此元素向右移动时会逐渐消失。

Tests

tests:
  - text: fade的<code>keyframes</code>规则应将<code>opacity</code>属性设置为0.1为50
    testString: 'assert(code.match(/@keyframes fade\s*?{\s*?50%\s*?{\s*?(?:left:\s*?60%;\s*?opacity:\s*?0?\.1;|opacity:\s*?0?\.1;\s*?left:\s*?60%;)/gi), "The <code>keyframes</code> rule for fade should set the <code>opacity</code> property to 0.1 at 50%.");'

Challenge Seed

<style>

  #ball {
    width: 70px;
    height: 70px;
    margin: 50px auto;
    position: fixed;
    left: 20%;
    border-radius: 50%;
    background: linear-gradient(
      35deg,
      #ccffff,
      #ffcccc
    );
    animation-name: fade;
    animation-duration: 3s;
  }

  @keyframes fade {
    50% {
      left: 60%;

    }
  }

</style>

<div id="ball"></div>

Solution

// solution required