--- id: 587d78a7367417b2b2512ae1 title: Create Movement Using CSS Animation localeTitle: Crear movimiento usando la animación CSS challengeType: 0 videoUrl: '' --- ## Description
Cuando los elementos tienen una position específica, como fixed o relative , las propiedades de desplazamiento de CSS right , left , top y bottom se pueden usar en las reglas de animación para crear movimiento. Como se muestra en el ejemplo a continuación, puede empujar el elemento hacia abajo y luego hacia arriba configurando la propiedad top del 50% fotograma clave a 50px, pero configurándolo en 0px para el primer ( 0% ) y el último ( 100% ) fotograma clave .
@keyframes rainbow {
  0% {
    background-color: blue;
    top: 0px;
  }
  50% {
    background-color: green;
    top: 50px;
  }
  100% {
    background-color: yellow;
    top: 0px;
  }
}
## Instructions
Agrega un movimiento horizontal a la animación div . Usando la propiedad de desplazamiento a la left , agregue a la regla @keyframes para que rainbow comience en 0 píxeles al 0% , se mueva a 25 píxeles al 50% y termine a -25 píxeles al 100% . No reemplace la propiedad top en el editor: la animación debe tener un movimiento vertical y horizontal.
## Tests
```yml tests: - text: La regla @keyframes para 0% debe usar el desplazamiento left de 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 @keyframes rule for 0% should use the left offset of 0px.");' - text: La regla @keyframes para el 50% debe usar el desplazamiento left de 25px. testString: 'assert(code.match(/50%\s*?{\s*?background-color:\s*?green;\s*?top:\s*?50px;\s*?left:\s*?25px;\s*?}/gi), "The @keyframes rule for 50% should use the left offset of 25px.");' - text: La regla @keyframes para el 100% debe usar el desplazamiento left de -25px. testString: 'assert(code.match(/100%\s*?{\s*?background-color:\s*?yellow;\s*?top:\s*?0(px)?;\s*?left:\s*?-25px;\s*?}/gi), "The @keyframes rule for 100% should use the left offset of -25px.");' ```
## Challenge Seed
```html
```
## Solution
```js var code = "@keyframes rainbow {0% {background-color: blue; top: 0px; left: 0px;} 50% {background-color: green; top: 50px; left: 25px;} 100% {background-color: yellow; top: 0px; left:-25px;}}" ```