2018-10-10 22:03:03 +00:00
|
|
|
---
|
|
|
|
id: 587d78a7367417b2b2512ae2
|
|
|
|
challengeType: 0
|
2020-02-11 07:46:34 +00:00
|
|
|
videoUrl: 'https://scrimba.com/c/cGJqqAE'
|
|
|
|
forumTopicId: 301054
|
2020-10-01 15:54:21 +00:00
|
|
|
title: 通过从左到右淡化元素来创建视觉方向
|
2018-10-10 22:03:03 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
## Description
|
2020-02-11 07:46:34 +00:00
|
|
|
<section id='description'>
|
|
|
|
在本关里,你将要改变动画元素的 <code>opacity</code>,使其在到达屏幕右侧时渐隐。
|
|
|
|
在展示的动画里,具有渐变背景的圆形元素在 50% 标记的 <code>@keyframes</code> 规则处向右移动。
|
|
|
|
</section>
|
2018-10-10 22:03:03 +00:00
|
|
|
|
|
|
|
## Instructions
|
2020-02-11 07:46:34 +00:00
|
|
|
<section id='instructions'>
|
|
|
|
使用 id 选择器选择 id 为 <code>ball</code> 的元素,在 <code>50%</code> 里添加 <code>opacity</code> 属性并赋值 0.1,使其在向右移动时渐隐。
|
|
|
|
</section>
|
2018-10-10 22:03:03 +00:00
|
|
|
|
|
|
|
## Tests
|
|
|
|
<section id='tests'>
|
|
|
|
|
|
|
|
```yml
|
|
|
|
tests:
|
2020-02-11 07:46:34 +00:00
|
|
|
- text: '50% 处 <code>keyframes</code> 规则应该设置 <code>opacity</code> 属性值为 0.1 以使其渐隐。'
|
2020-02-17 16:40:55 +00:00
|
|
|
testString: 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-10-10 22:03:03 +00:00
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
## Challenge Seed
|
|
|
|
<section id='challengeSeed'>
|
|
|
|
|
|
|
|
<div id='html-seed'>
|
|
|
|
|
|
|
|
```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%;
|
2020-02-11 07:46:34 +00:00
|
|
|
|
2018-10-10 22:03:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
<div id="ball"></div>
|
|
|
|
```
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
## Solution
|
|
|
|
<section id='solution'>
|
|
|
|
|
2020-02-11 07:46:34 +00:00
|
|
|
|
|
|
|
```html
|
2018-10-10 22:03:03 +00:00
|
|
|
// solution required
|
|
|
|
```
|
2020-02-11 07:46:34 +00:00
|
|
|
|
2018-10-10 22:03:03 +00:00
|
|
|
</section>
|
2020-02-11 07:46:34 +00:00
|
|
|
|