freeCodeCamp/curriculum/challenges/chinese/01-responsive-web-design/applied-visual-design/modify-fill-mode-of-an-anim...

2.1 KiB

id title challengeType videoUrl localeTitle
58a7a6ebf9a6318348e2d5aa Modify Fill Mode of an Animation 0 修改动画的填充模式

Description

这很好,但它还不能正常工作。注意动画在500ms过后如何重置,导致按钮恢复为原始颜色。您希望按钮保持突出显示。这可以通过设置来完成animation-fill-mode属性forwardsanimation-fill-mode指定动画完成时应用于元素的样式。您可以这样设置: animation-fill-mode: forwards;

Instructions

设置button:hoveranimation-fill-mode属性button:hover to forwards以便当用户将鼠标悬停在按钮上时按钮保持突出显示。

Tests

tests:
  - text: '<code>button:hover</code>应该具有值为<code>forwards</code>的<code>animation-fill-mode</code>属性。'
    testString: 'assert(code.match(/button\s*?:\s*?hover\s*?{[\s\S]*animation-fill-mode\s*?:\s*?forwards\s*?;[\s\S]*}/gi) && code.match(/button\s*?:\s*?hover\s*?{[\s\S]*animation-name\s*?:\s*?background-color\s*?;[\s\S]*}/gi) && code.match(/button\s*?:\s*?hover\s*?{[\s\S]*animation-duration\s*?:\s*?500ms\s*?;[\s\S]*}/gi), "<code>button:hover</code> should have a <code>animation-fill-mode</code> property with a value of <code>forwards</code>.");'

Challenge Seed

<style>
  button {
    border-radius: 5px;
    color: white;
    background-color: #0F5897;
    padding: 5px 10px 8px 10px;
  }
  button:hover {
    animation-name: background-color;
    animation-duration: 500ms;
    /* add your code below this line */

    /* add your code above this line */
  }
  @keyframes background-color {
    100% {
      background-color: #4791d0;
    }
  }
</style>
<button>Register</button>

Solution

// solution required