96 lines
1.8 KiB
Markdown
96 lines
1.8 KiB
Markdown
![]() |
---
|
||
|
id: 587d78a5367417b2b2512ad9
|
||
|
title: CSS の Transform scale プロパティを使用して要素のサイズを変更する
|
||
|
challengeType: 0
|
||
|
videoUrl: 'https://scrimba.com/c/c2MZVSg'
|
||
|
forumTopicId: 301076
|
||
|
dashedName: use-the-css-transform-scale-property-to-change-the-size-of-an-element
|
||
|
---
|
||
|
|
||
|
# --description--
|
||
|
|
||
|
要素の大きさを変更するために、CSS には `transform` プロパティと `scale()` 関数があります。 以下のコードの例は、ページ上のすべての段落要素のサイズを 2 倍にします。
|
||
|
|
||
|
```css
|
||
|
p {
|
||
|
transform: scale(2);
|
||
|
}
|
||
|
```
|
||
|
|
||
|
# --instructions--
|
||
|
|
||
|
id が `ball2` の要素のサイズを、元のサイズの 1.5 倍の大きさにしてください。
|
||
|
|
||
|
# --hints--
|
||
|
|
||
|
`#ball2` の `transform` プロパティを、サイズが 1.5 倍に拡大するように設定してください。
|
||
|
|
||
|
```js
|
||
|
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
|
||
|
)
|
||
|
);
|
||
|
```
|
||
|
|
||
|
# --seed--
|
||
|
|
||
|
## --seed-contents--
|
||
|
|
||
|
```html
|
||
|
<style>
|
||
|
.ball {
|
||
|
width: 40px;
|
||
|
height: 40px;
|
||
|
margin: 50 auto;
|
||
|
position: fixed;
|
||
|
background: linear-gradient(
|
||
|
35deg,
|
||
|
#ccffff,
|
||
|
#ffcccc
|
||
|
);
|
||
|
border-radius: 50%;
|
||
|
}
|
||
|
#ball1 {
|
||
|
left: 20%;
|
||
|
}
|
||
|
#ball2 {
|
||
|
left: 65%;
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
</style>
|
||
|
|
||
|
<div class="ball" id= "ball1"></div>
|
||
|
<div class="ball" id= "ball2"></div>
|
||
|
```
|
||
|
|
||
|
# --solutions--
|
||
|
|
||
|
```html
|
||
|
<style>
|
||
|
.ball {
|
||
|
width: 40px;
|
||
|
height: 40px;
|
||
|
margin: 50 auto;
|
||
|
position: fixed;
|
||
|
background: linear-gradient(
|
||
|
35deg,
|
||
|
#ccffff,
|
||
|
#ffcccc
|
||
|
);
|
||
|
border-radius: 50%;
|
||
|
}
|
||
|
#ball1 {
|
||
|
left: 20%;
|
||
|
}
|
||
|
#ball2 {
|
||
|
left: 65%;
|
||
|
transform: scale(1.5);
|
||
|
}
|
||
|
</style>
|
||
|
<div class="ball" id= "ball1"></div>
|
||
|
<div class="ball" id= "ball2"></div>
|
||
|
```
|