2018-09-30 23:01:58 +01:00
---
id: 587d78a7367417b2b2512ae2
title: Create Visual Direction by Fading an Element from Left to Right
challengeType: 0
videoUrl: 'https://scrimba.com/c/cGJqqAE'
2019-08-05 09:17:33 -07:00
forumTopicId: 301054
2021-01-13 03:31:00 +01:00
dashedName: create-visual-direction-by-fading-an-element-from-left-to-right
2018-09-30 23:01:58 +01:00
---
2020-11-27 19:02:05 +01:00
# --description--
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
For this challenge, you'll change the `opacity` of an animated element so it gradually fades as it reaches the right side of the screen.
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
In the displayed animation, the round element with the gradient background moves to the right by the 50% mark of the animation per the `@keyframes` rule.
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
# --instructions--
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
Target the element with the id of `ball` and add the `opacity` property set to 0.1 at `50%` , so the element fades as it moves to the right.
# --hints--
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
The `keyframes` rule for fade should set the `opacity` property to 0.1 at 50%.
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
```js
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
)
);
```
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
# --seed--
## --seed-contents--
2018-09-30 23:01:58 +01:00
```html
< 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%;
2018-10-08 01:01:53 +01:00
2018-09-30 23:01:58 +01:00
}
}
< / style >
< div id = "ball" > < / div >
```
2020-11-27 19:02:05 +01:00
# --solutions--
2018-09-30 23:01:58 +01:00
2019-04-29 01:13:38 +07:00
```html
< 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%;
opacity: 0.1;
}
}
< / style >
< div id = "ball" > < / div >
2018-09-30 23:01:58 +01:00
```