3.8 KiB
3.8 KiB
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
587d78a7367417b2b2512ae1 | Create Movement Using CSS Animation | 0 | Создание движения с использованием анимации CSS |
Description
position
, например fixed
или relative
, свойства смещения CSS right
, left
, top
и bottom
могут использоваться в правилах анимации для создания движения. Как показано в приведенном ниже примере, вы можете нажать элемент вниз, а затем вверх, установив top
свойство 50%
ключевого кадра на 50%
пикселей, но установив его на 0px для первого ( 0%
) и последнего ( 100%
) ключевого кадра. @keyframes rainbow {
0% {
background-color: blue;
top: 0px;
}
50% {
фон-цвет: зеленый;
top: 50px;
}
100% {
background-color: желтый;
top: 0px;
}
}
Instructions
div
. Используя свойство left
offset, добавьте правило @keyframes
так что радуга начинается с 0 пикселей на 0%
, перемещается до 25 пикселей с 50%
и заканчивается на -25 пикселей при 100%
. Не заменяйте top
свойство в редакторе - анимация должна иметь как вертикальное, так и горизонтальное движение. Tests
tests:
- text: Правило <code>@keyframes</code> для <code>0%</code> должно использовать <code>left</code> смещение 0px.
testString: 'assert(code.match(/0%\s*?{\s*?background-color:\s*?blue;\s*?top:\s*?0(px)?;\s*?left:\s*?0(px)?;\s*?}/gi), "The <code>@keyframes</code> rule for <code>0%</code> should use the <code>left</code> offset of 0px.");'
- text: Правило <code>@keyframes</code> для <code>50%</code> должно использовать <code>left</code> смещение 25px.
testString: 'assert(code.match(/50%\s*?{\s*?background-color:\s*?green;\s*?top:\s*?50px;\s*?left:\s*?25px;\s*?}/gi), "The <code>@keyframes</code> rule for <code>50%</code> should use the <code>left</code> offset of 25px.");'
- text: Правило <code>@keyframes</code> для <code>100%</code> должно использовать <code>left</code> смещение -25px.
testString: 'assert(code.match(/100%\s*?{\s*?background-color:\s*?yellow;\s*?top:\s*?0(px)?;\s*?left:\s*?-25px;\s*?}/gi), "The <code>@keyframes</code> rule for <code>100%</code> should use the <code>left</code> offset of -25px.");'
Challenge Seed
<style>
div {
height: 40px;
width: 70%;
background: black;
margin: 50px auto;
border-radius: 5px;
position: relative;
}
#rect {
animation-name: rainbow;
animation-duration: 4s;
}
@keyframes rainbow {
0% {
background-color: blue;
top: 0px;
}
50% {
background-color: green;
top: 50px;
}
100% {
background-color: yellow;
top: 0px;
}
}
</style>
<div id="rect"></div>
Solution
// solution required