Files
freeCodeCamp/curriculum/challenges/russian/01-responsive-web-design/applied-visual-design/use-css-animation-to-change-the-hover-state-of-a-button.russian.md

2.8 KiB
Raw Blame History

id, title, challengeType, videoUrl, forumTopicId, localeTitle
id title challengeType videoUrl forumTopicId localeTitle
587d78a7367417b2b2512ae0 Use CSS Animation to Change the Hover State of a Button 0 https://scrimba.com/c/cg4vZAa 301073 Использование анимации CSS для изменения состояния наведения кнопки

Description

Вы можете использовать CSS @keyframes для изменения цвета кнопки в состоянии зависания. Ниже приведен пример изменения ширины изображения при наведении:
<Стиль>
img: hover {
animation-name: width;
продолжительность анимации: 500 мс;
}

Ширина @keyframes {
100% {
ширина: 40 пикселей;
}
}
</ Стиль>

<img src = "https://bit.ly/smallgooglelogo" alt = "Логотип Google" />

Instructions

Обратите внимание, что ms обозначает миллисекунды, где 1000 мс равно 1 с. Используйте CSS @keyframes чтобы изменить background-color элемента button чтобы он стал #4791d0 когда пользователь #4791d0 на него курсор. Правило @keyframes должно содержать только запись на 100% .

Tests

tests:
  - text: The @keyframes rule should use the <code>animation-name</code> background-color.
    testString: assert(code.match(/@keyframes\s+?background-color\s*?{/g));
  - text: There should be one rule under <code>@keyframes</code> that changes the <code>background-color</code> to <code>#4791d0</code> at 100%.
    testString: assert(code.match(/100%\s*?{\s*?background-color:\s*?#4791d0;\s*?}/gi));

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;
  }


</style>

<button>Register</button>

Solution

<style>
  button {
    border-radius: 5px;
    color: white;
    background-color: #0F5897;
    padding: 5px 10px 8px 10px;
  }

  button:hover {
    animation-name: background-color;
    animation-duration: 500ms;
  }

  @keyframes background-color {
    100% {
      background-color: #4791d0;
    }
  }
</style>
<button>Register</button>