2018-10-10 18:03:03 -04:00
|
|
|
---
|
|
|
|
id: 587d78a5367417b2b2512ad9
|
|
|
|
title: Use the CSS Transform scale Property to Change the Size of an Element
|
|
|
|
challengeType: 0
|
2020-02-11 15:46:34 +08:00
|
|
|
videoUrl: 'https://scrimba.com/c/c2MZVSg'
|
|
|
|
forumTopicId: 301076
|
|
|
|
localeTitle: 使用 CSS Transform scale 属性可以更改元素的大小
|
2018-10-10 18:03:03 -04:00
|
|
|
---
|
|
|
|
|
|
|
|
## Description
|
2020-02-11 15:46:34 +08:00
|
|
|
<section id='description'>
|
|
|
|
CSS 属性 <code>transform</code> 里面的 <code>scale()</code> 函数,可以用来改变元素的显示比例。下面的例子把页面的段落元素放大了 2 倍:
|
|
|
|
|
|
|
|
```css
|
|
|
|
p {
|
|
|
|
transform: scale(2);
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
</section>
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
## Instructions
|
2020-02-11 15:46:34 +08:00
|
|
|
<section id='instructions'>
|
|
|
|
把 id 为 <code>ball2</code> 的元素放大到原始大小的 1.5 倍。
|
|
|
|
</section>
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
## Tests
|
|
|
|
<section id='tests'>
|
|
|
|
|
|
|
|
```yml
|
|
|
|
tests:
|
2020-02-11 15:46:34 +08:00
|
|
|
- text: '<code>#ball2</code> 的 <code>transform</code> 属性应该为原始大小的 1.5 倍。'
|
|
|
|
testString: 'assert(code.match(/#ball2\s*?{\s*?left:\s*?65%;\s*?transform:\s*?scale\(1\.5\);\s*?}|#ball2\s*?{\s*?transform:\s*?scale\(1\.5\);\s*?left:\s*?65%;\s*?}/gi), ''<code>#ball2</code> 的 <code>transform</code> 属性应该为原始大小的 1.5 倍。'');'
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
## Challenge Seed
|
|
|
|
<section id='challengeSeed'>
|
|
|
|
|
|
|
|
<div id='html-seed'>
|
|
|
|
|
|
|
|
```html
|
|
|
|
<style>
|
2020-02-11 15:46:34 +08:00
|
|
|
.ball {
|
2018-10-10 18:03:03 -04:00
|
|
|
width: 40px;
|
|
|
|
height: 40px;
|
|
|
|
margin: 50 auto;
|
|
|
|
position: fixed;
|
|
|
|
background: linear-gradient(
|
|
|
|
35deg,
|
|
|
|
#ccffff,
|
|
|
|
#ffcccc
|
|
|
|
);
|
|
|
|
border-radius: 50%;
|
|
|
|
}
|
|
|
|
#ball1 {
|
|
|
|
left: 20%;
|
|
|
|
}
|
|
|
|
#ball2 {
|
|
|
|
left: 65%;
|
2020-02-11 15:46:34 +08:00
|
|
|
|
2018-10-10 18:03:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
<div class="ball" id= "ball1"></div>
|
|
|
|
<div class="ball" id= "ball2"></div>
|
|
|
|
```
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
## Solution
|
|
|
|
<section id='solution'>
|
|
|
|
|
2020-02-11 15:46:34 +08:00
|
|
|
|
|
|
|
```html
|
2018-10-10 18:03:03 -04:00
|
|
|
// solution required
|
|
|
|
```
|
2020-02-11 15:46:34 +08:00
|
|
|
|
2018-10-10 18:03:03 -04:00
|
|
|
</section>
|
2020-02-11 15:46:34 +08:00
|
|
|
|