chore(i18n,learn): processed translations (#44851)

This commit is contained in:
camperbot
2022-01-21 01:00:18 +05:30
committed by GitHub
parent f866718a3d
commit 5c868af2b8
1696 changed files with 159426 additions and 69 deletions

View File

@ -0,0 +1,115 @@
---
id: bad87fee1348bd9aedf08823
title: 要素に負の値のマージンを追加する
challengeType: 0
videoUrl: 'https://scrimba.com/c/cnpyGs3'
forumTopicId: 16166
dashedName: add-a-negative-margin-to-an-element
---
# --description--
要素の `margin` は、要素の `border` とその外側の要素の間のスペースを制御します。
要素の `margin` を負の値に設定すると、要素は大きくなります。
# --instructions--
`margin` を赤い四角の値のように負の値に設定してみましょう。
青い四角の `margin``-15px` に変更し、黄色い四角の横幅いっぱい広がるようにしてください。
# --hints--
`blue-box` クラスは、要素に `-15px``margin` を与える必要があります。
```js
assert($('.blue-box').css('margin-top') === '-15px');
```
# --seed--
## --seed-contents--
```html
<style>
.injected-text {
margin-bottom: -25px;
text-align: center;
}
.box {
border-style: solid;
border-color: black;
border-width: 5px;
text-align: center;
}
.yellow-box {
background-color: yellow;
padding: 10px;
}
.red-box {
background-color: crimson;
color: #fff;
padding: 20px;
margin: -15px;
}
.blue-box {
background-color: blue;
color: #fff;
padding: 20px;
margin: 20px;
}
</style>
<div class="box yellow-box">
<h5 class="box red-box">padding</h5>
<h5 class="box blue-box">padding</h5>
</div>
```
# --solutions--
```html
<style>
.injected-text {
margin-bottom: -25px;
text-align: center;
}
.box {
border-style: solid;
border-color: black;
border-width: 5px;
text-align: center;
}
.yellow-box {
background-color: yellow;
padding: 10px;
}
.red-box {
background-color: crimson;
color: #fff;
padding: 20px;
margin: -15px;
}
.blue-box {
background-color: blue;
color: #fff;
padding: 20px;
margin: 20px;
margin-top: -15px;
}
</style>
<div class="box yellow-box">
<h5 class="box red-box">padding</h5>
<h5 class="box blue-box">padding</h5>
</div>
```

View File

@ -0,0 +1,190 @@
---
id: bad87fee1348bd9bedf08813
title: 要素の周りに境界線を追加する
challengeType: 0
videoUrl: 'https://scrimba.com/c/c2MvnHZ'
forumTopicId: 16630
dashedName: add-borders-around-your-elements
---
# --description--
CSSの border には `style``color` および `width` のようなプロパティがあります。
例えば、ある HTML 要素の周りに赤色の5ピクセルの境界線を作成したい場合、次のようなクラスを使えます:
```html
<style>
.thin-red-border {
border-color: red;
border-width: 5px;
border-style: solid;
}
</style>
```
# --instructions--
`thick-green-border` というクラスを作成しましょう。 このクラスは HTML 要素の周りに 10px、実線 (solid)、緑色の境界線を追加するようにしてください。 猫の写真にこのクラスを適用してください。
1 つの要素に複数のクラスを適用するには、`class` 属性に各クラス名を半角スペースで区切って指定することを覚えておいてください。 例えば次のようになります:
```html
<img class="class1 class2">
```
# --hints--
`img` 要素にはクラス `smaller-image` が必要です。
```js
assert($('img').hasClass('smaller-image'));
```
`img` 要素にはクラス `thick-green-border` が必要です。
```js
assert($('img').hasClass('thick-green-border'));
```
画像の境界線の幅は `10px` である必要があります。
```js
assert(
$('img').hasClass('thick-green-border') &&
parseInt($('img').css('border-top-width'), 10) >= 8 &&
parseInt($('img').css('border-top-width'), 10) <= 12
);
```
画像の境界線のスタイルは `solid` である必要があります。
```js
assert($('img').css('border-right-style') === 'solid');
```
`img` 要素の周りの境界線は緑色でなければなりません。
```js
assert($('img').css('border-left-color') === 'rgb(0, 128, 0)');
```
# --seed--
## --seed-contents--
```html
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
.red-text {
color: red;
}
h2 {
font-family: Lobster, monospace;
}
p {
font-size: 16px;
font-family: monospace;
}
.smaller-image {
width: 100px;
}
</style>
<h2 class="red-text">CatPhotoApp</h2>
<main>
<p class="red-text">Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img class="smaller-image" src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
<div>
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
</div>
<form action="https://freecatphotoapp.com/submit-cat-photo">
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
<label><input type="checkbox" name="personality" checked> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Energetic</label><br>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
```
# --solutions--
```html
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
.red-text {
color: red;
}
h2 {
font-family: Lobster, monospace;
}
p {
font-size: 16px;
font-family: monospace;
}
.smaller-image {
width: 100px;
}
.thick-green-border {
border-width: 10px;
border-color: green;
border-style: solid;
}
</style>
<h2 class="red-text">CatPhotoApp</h2>
<main>
<p class="red-text">Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img class="smaller-image thick-green-border" src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
<div>
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
</div>
<form action="https://freecatphotoapp.com/submit-cat-photo">
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
<label><input type="checkbox" name="personality" checked> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Energetic</label><br>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
```

View File

@ -0,0 +1,136 @@
---
id: bad87fee1248bd9aedf08824
title: 要素の四辺に異なるマージンを追加する
challengeType: 0
videoUrl: 'https://scrimba.com/c/cg4RWh4'
forumTopicId: 16633
dashedName: add-different-margins-to-each-side-of-an-element
---
# --description--
それぞれの側で異なる `margin` を持つように要素をカスタマイズしたい場合もあるでしょう。
CSS では `margin-top`, `margin-right`, `margin-bottom`, `margin-left` のプロパティを使用して、要素の 4 つの辺それぞれの `margin` を制御することができます。
# --instructions--
青い四角の `margin` を上側と左側は `40px`、下側と右側は `20px` に設定してください。
# --hints--
`blue-box` クラスは、要素の上側に `40px``margin` を与える必要があります。
```js
assert($('.blue-box').css('margin-top') === '40px');
```
`blue-box` クラスは、要素の右側に `20px``margin` を与える必要があります。
```js
assert($('.blue-box').css('margin-right') === '20px');
```
`blue-box` クラスは、要素の下側に `20px``margin` を与える必要があります。
```js
assert($('.blue-box').css('margin-bottom') === '20px');
```
`blue-box` クラスは、要素の左側に `40px``margin` を与える必要があります。
```js
assert($('.blue-box').css('margin-left') === '40px');
```
# --seed--
## --seed-contents--
```html
<style>
.injected-text {
margin-bottom: -25px;
text-align: center;
}
.box {
border-style: solid;
border-color: black;
border-width: 5px;
text-align: center;
}
.yellow-box {
background-color: yellow;
padding: 10px;
}
.red-box {
background-color: crimson;
color: #fff;
margin-top: 40px;
margin-right: 20px;
margin-bottom: 20px;
margin-left: 40px;
}
.blue-box {
background-color: blue;
color: #fff;
}
</style>
<h5 class="injected-text">margin</h5>
<div class="box yellow-box">
<h5 class="box red-box">padding</h5>
<h5 class="box blue-box">padding</h5>
</div>
```
# --solutions--
```html
<style>
.injected-text {
margin-bottom: -25px;
text-align: center;
}
.box {
border-style: solid;
border-color: black;
border-width: 5px;
text-align: center;
}
.yellow-box {
background-color: yellow;
padding: 10px;
}
.red-box {
background-color: crimson;
color: #fff;
margin-top: 40px;
margin-right: 20px;
margin-bottom: 20px;
margin-left: 40px;
}
.blue-box {
background-color: blue;
color: #fff;
margin-top: 40px;
margin-right: 20px;
margin-bottom: 20px;
margin-left: 40px;
}
</style>
<h5 class="injected-text">margin</h5>
<div class="box yellow-box">
<h5 class="box red-box">padding</h5>
<h5 class="box blue-box">padding</h5>
</div>
```

View File

@ -0,0 +1,136 @@
---
id: bad87fee1348bd9aedf08824
title: 要素の四辺に異なるパディングを追加する
challengeType: 0
videoUrl: 'https://scrimba.com/c/cB7mwUw'
forumTopicId: 16634
dashedName: add-different-padding-to-each-side-of-an-element
---
# --description--
それぞれの側で異なる `padding` の値を持つように要素をカスタマイズしたい場合もあるでしょう。
CSS では `padding-top`, `padding-right`, `padding-bottom`, `padding-left` のプロパティを使用して、要素の 4 つの辺それぞれの `padding` を制御することができます。
# --instructions--
青い四角の `padding` を上側と左側は `40px`、下側と右側は `20px` に設定してください。
# --hints--
`blue-box` クラスは、要素の上側に `40px``padding` を与える必要があります。
```js
assert($('.blue-box').css('padding-top') === '40px');
```
`blue-box` クラスは、要素の右側に `20px``padding` を与える必要があります。
```js
assert($('.blue-box').css('padding-right') === '20px');
```
`blue-box` クラスは、要素の下側に `20px``padding` を与える必要があります。
```js
assert($('.blue-box').css('padding-bottom') === '20px');
```
`blue-box` クラスは、要素の左側に `40px``padding` を与える必要があります。
```js
assert($('.blue-box').css('padding-left') === '40px');
```
# --seed--
## --seed-contents--
```html
<style>
.injected-text {
margin-bottom: -25px;
text-align: center;
}
.box {
border-style: solid;
border-color: black;
border-width: 5px;
text-align: center;
}
.yellow-box {
background-color: yellow;
padding: 10px;
}
.red-box {
background-color: crimson;
color: #fff;
padding-top: 40px;
padding-right: 20px;
padding-bottom: 20px;
padding-left: 40px;
}
.blue-box {
background-color: blue;
color: #fff;
}
</style>
<h5 class="injected-text">margin</h5>
<div class="box yellow-box">
<h5 class="box red-box">padding</h5>
<h5 class="box blue-box">padding</h5>
</div>
```
# --solutions--
```html
<style>
.injected-text {
margin-bottom: -25px;
text-align: center;
}
.box {
border-style: solid;
border-color: black;
border-width: 5px;
text-align: center;
}
.yellow-box {
background-color: yellow;
padding: 10px;
}
.red-box {
background-color: crimson;
color: #fff;
padding-top: 40px;
padding-right: 20px;
padding-bottom: 20px;
padding-left: 40px;
}
.blue-box {
background-color: blue;
color: #fff;
padding-top: 40px;
padding-right: 20px;
padding-bottom: 20px;
padding-left: 40px;
}
</style>
<h5 class="injected-text">margin</h5>
<div class="box yellow-box">
<h5 class="box red-box">padding</h5>
<h5 class="box blue-box">padding</h5>
</div>
```

View File

@ -0,0 +1,164 @@
---
id: bad87fee1348bd9aedf08814
title: border-radius で角を丸くする
challengeType: 0
videoUrl: 'https://scrimba.com/c/cbZm2hg'
forumTopicId: 16649
dashedName: add-rounded-corners-with-border-radius
---
# --description--
今、猫の写真の角はとがっています。 `border-radius` という CSS プロパティで、この角を丸くすることができます。
# --instructions--
`border-radius` はピクセルで指定できます。 猫の写真の `border-radius``10px` にしましょう。
**注:** このチャレンジは、複数の解答が考えられます。 例えば、`border-radius``.thick-green-border` クラスと `.smaller-image` クラスのどちらに追加しても差し支えありません。
# --hints--
画像要素には `thick-green-border` クラスが必要です。
```js
assert($('img').hasClass('thick-green-border'));
```
画像の境界線の角の半径は `10px` に設定されている必要があります。
```js
assert(
$('img').css('border-top-left-radius') === '10px' &&
$('img').css('border-top-right-radius') === '10px' &&
$('img').css('border-bottom-left-radius') === '10px' &&
$('img').css('border-bottom-right-radius') === '10px'
);
```
# --seed--
## --seed-contents--
```html
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
.red-text {
color: red;
}
h2 {
font-family: Lobster, monospace;
}
p {
font-size: 16px;
font-family: monospace;
}
.thick-green-border {
border-color: green;
border-width: 10px;
border-style: solid;
}
.smaller-image {
width: 100px;
}
</style>
<h2 class="red-text">CatPhotoApp</h2>
<main>
<p class="red-text">Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img class="smaller-image thick-green-border" src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
<div>
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
</div>
<form action="https://freecatphotoapp.com/submit-cat-photo">
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
<label><input type="checkbox" name="personality" checked> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Energetic</label><br>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
```
# --solutions--
```html
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
.red-text {
color: red;
}
h2 {
font-family: Lobster, monospace;
}
p {
font-size: 16px;
font-family: monospace;
}
.thick-green-border {
border-color: green;
border-width: 10px;
border-style: solid;
}
.smaller-image {
width: 100px;
border-radius: 10px;
}
</style>
<h2 class="red-text">CatPhotoApp</h2>
<main>
<p class="red-text">Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img class="smaller-image thick-green-border" src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
<div>
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
</div>
<form action="https://freecatphotoapp.com/submit-cat-photo">
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
<label><input type="checkbox" name="personality" checked> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Energetic</label><br>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
```

View File

@ -0,0 +1,116 @@
---
id: bad87fee1348bd9aedf08822
title: 要素のマージンを調整する
challengeType: 0
videoUrl: 'https://scrimba.com/c/cVJarHW'
forumTopicId: 16654
dashedName: adjust-the-margin-of-an-element
---
# --description--
要素の `margin` は、要素の `border` とその外側の要素の間のスペースを制御します。
ここでは、青い四角と赤い四角が黄色い四角の中に入れ子になっています。 赤い四角は青い四角より大きい `margin` を持っており、そのため小さく表示されていることに注目してください。
青い四角の `margin` を増やすと、その枠線と周囲の要素の間の距離が増えます。
# --instructions--
青い四角の `margin` が赤い四角と同じになるように変更してください。
# --hints--
`blue-box` クラスは、要素に `20px``margin` を与える必要があります。
```js
assert($('.blue-box').css('margin-top') === '20px');
```
# --seed--
## --seed-contents--
```html
<style>
.injected-text {
margin-bottom: -25px;
text-align: center;
}
.box {
border-style: solid;
border-color: black;
border-width: 5px;
text-align: center;
}
.yellow-box {
background-color: yellow;
padding: 10px;
}
.red-box {
background-color: crimson;
color: #fff;
padding: 20px;
margin: 20px;
}
.blue-box {
background-color: blue;
color: #fff;
padding: 20px;
margin: 10px;
}
</style>
<h5 class="injected-text">margin</h5>
<div class="box yellow-box">
<h5 class="box red-box">padding</h5>
<h5 class="box blue-box">padding</h5>
</div>
```
# --solutions--
```html
<style>
.injected-text {
margin-bottom: -25px;
text-align: center;
}
.box {
border-style: solid;
border-color: black;
border-width: 5px;
text-align: center;
}
.yellow-box {
background-color: yellow;
padding: 10px;
}
.red-box {
background-color: crimson;
color: #fff;
padding: 20px;
margin: 20px;
}
.blue-box {
background-color: blue;
color: #fff;
padding: 20px;
margin: 20px;
}
</style>
<h5 class="injected-text">margin</h5>
<div class="box yellow-box">
<h5 class="box red-box">padding</h5>
<h5 class="box blue-box">padding</h5>
</div>
```

View File

@ -0,0 +1,118 @@
---
id: bad88fee1348bd9aedf08825
title: 要素のパディングを調整する
challengeType: 0
videoUrl: 'https://scrimba.com/c/cED8ZC2'
forumTopicId: 301083
dashedName: adjust-the-padding-of-an-element
---
# --description--
では猫の写真アプリは一旦置いておいて、HTML のスタイル調整についてもっと学びましょう。
すでに気づいているかもしれませんが、すべての HTML 要素は基本的に小さな長方形です。
3 つの重要なプロパティが、各 HTML 要素を囲むスペースを制御します。`padding``border`、そして `margin` です。
要素の `padding` は、要素の中身と `border` の間のスペースを制御します。
ここでは、青い四角と赤い四角が黄色い四角の中に入れ子になっています。 赤い四角は青い四角よりも `padding` が多いことに注目してください。
青い四角の `padding` を増やすと、テキストと枠線の間の距離 (`padding`) が増えます。
# --instructions--
青い四角の `padding` が赤い四角と同じになるように変更してください。
# --hints--
`blue-box` クラスは、要素に `20px``padding` を与える必要があります。
```js
assert($('.blue-box').css('padding-top') === '20px');
```
# --seed--
## --seed-contents--
```html
<style>
.injected-text {
margin-bottom: -25px;
text-align: center;
}
.box {
border-style: solid;
border-color: black;
border-width: 5px;
text-align: center;
}
.yellow-box {
background-color: yellow;
padding: 10px;
}
.red-box {
background-color: crimson;
color: #fff;
padding: 20px;
}
.blue-box {
background-color: blue;
color: #fff;
padding: 10px;
}
</style>
<h5 class="injected-text">margin</h5>
<div class="box yellow-box">
<h5 class="box red-box">padding</h5>
<h5 class="box blue-box">padding</h5>
</div>
```
# --solutions--
```html
<style>
.injected-text {
margin-bottom: -25px;
text-align: center;
}
.box {
border-style: solid;
border-color: black;
border-width: 5px;
text-align: center;
}
.yellow-box {
background-color: yellow;
padding: 10px;
}
.red-box {
background-color: crimson;
color: #fff;
padding: 20px;
}
.blue-box {
background-color: blue;
color: #fff;
padding: 20px;
}
</style>
<h5 class="injected-text">margin</h5>
<div class="box yellow-box">
<h5 class="box red-box">padding</h5>
<h5 class="box blue-box">padding</h5>
</div>
```

View File

@ -0,0 +1,272 @@
---
id: 5a9d7286424fe3d0e10cad13
title: CSS 変数にフォールバック値を追加する
challengeType: 0
videoUrl: 'https://scrimba.com/c/c6bDNfp'
forumTopicId: 301084
dashedName: attach-a-fallback-value-to-a-css-variable
---
# --description--
CSS プロパティの値として変数を使用する場合、指定された変数が無効な場合にブラウザが代わりに使用するフォールバック値を付けることができます。
**注:** このフォールバックはブラウザの互換性を高めるためのものではなく、また IE では動作しません。 むしろ、ブラウザが変数を見つけられない場合に表示する色を持つようにするために使用されます。
方法は次のとおりです:
```css
background: var(--penguin-skin, black);
```
これで、もし変数が設定されていなかった場合に背景色を `black` にすることができます。 これがデバッグに役立つことに注目してください。
# --instructions--
`.penguin-top` クラスと `.penguin-bottom` クラスに与えられている変数に問題があるようですね。 誤字を直すのではなく、`.penguin-top` クラスと `.penguin-bottom` クラスの `background` プロパティにフォールバック値 `black` を追加してみましょう。
# --hints--
`penguin-top` クラスの `background` プロパティのフォールバック値に `black` を使用してください。
```js
assert(
code.match(
/.penguin-top\s*?{[\s\S]*background\s*?:\s*?var\(\s*?--pengiun-skin\s*?,\s*?black\s*?\)\s*?;[\s\S]*}[\s\S]*.penguin-bottom\s{/gi
)
);
```
`penguin-bottom` クラスの `background` プロパティのフォールバック値に `black` を使用してください。
```js
assert(
code.match(
/.penguin-bottom\s*?{[\s\S]*background\s*?:\s*?var\(\s*?--pengiun-skin\s*?,\s*?black\s*?\)\s*?;[\s\S]*}/gi
)
);
```
# --seed--
## --seed-contents--
```html
<style>
.penguin {
--penguin-skin: black;
--penguin-belly: gray;
--penguin-beak: yellow;
position: relative;
margin: auto;
display: block;
margin-top: 5%;
width: 300px;
height: 300px;
}
.penguin-top {
top: 10%;
left: 25%;
/* Change code below this line */
background: var(--pengiun-skin);
/* Change code above this line */
width: 50%;
height: 45%;
border-radius: 70% 70% 60% 60%;
}
.penguin-bottom {
top: 40%;
left: 23.5%;
/* Change code below this line */
background: var(--pengiun-skin);
/* Change code above this line */
width: 53%;
height: 45%;
border-radius: 70% 70% 100% 100%;
}
.right-hand {
top: 0%;
left: -5%;
background: var(--penguin-skin, black);
width: 30%;
height: 60%;
border-radius: 30% 30% 120% 30%;
transform: rotate(45deg);
z-index: -1;
}
.left-hand {
top: 0%;
left: 75%;
background: var(--penguin-skin, black);
width: 30%;
height: 60%;
border-radius: 30% 30% 30% 120%;
transform: rotate(-45deg);
z-index: -1;
}
.right-cheek {
top: 15%;
left: 35%;
background: var(--penguin-belly, white);
width: 60%;
height: 70%;
border-radius: 70% 70% 60% 60%;
}
.left-cheek {
top: 15%;
left: 5%;
background: var(--penguin-belly, white);
width: 60%;
height: 70%;
border-radius: 70% 70% 60% 60%;
}
.belly {
top: 60%;
left: 2.5%;
background: var(--penguin-belly, white);
width: 95%;
height: 100%;
border-radius: 120% 120% 100% 100%;
}
.right-feet {
top: 85%;
left: 60%;
background: var(--penguin-beak, orange);
width: 15%;
height: 30%;
border-radius: 50% 50% 50% 50%;
transform: rotate(-80deg);
z-index: -2222;
}
.left-feet {
top: 85%;
left: 25%;
background: var(--penguin-beak, orange);
width: 15%;
height: 30%;
border-radius: 50% 50% 50% 50%;
transform: rotate(80deg);
z-index: -2222;
}
.right-eye {
top: 45%;
left: 60%;
background: black;
width: 15%;
height: 17%;
border-radius: 50%;
}
.left-eye {
top: 45%;
left: 25%;
background: black;
width: 15%;
height: 17%;
border-radius: 50%;
}
.sparkle {
top: 25%;
left: 15%;
background: white;
width: 35%;
height: 35%;
border-radius: 50%;
}
.blush-right {
top: 65%;
left: 15%;
background: pink;
width: 15%;
height: 10%;
border-radius: 50%;
}
.blush-left {
top: 65%;
left: 70%;
background: pink;
width: 15%;
height: 10%;
border-radius: 50%;
}
.beak-top {
top: 60%;
left: 40%;
background: var(--penguin-beak, orange);
width: 20%;
height: 10%;
border-radius: 50%;
}
.beak-bottom {
top: 65%;
left: 42%;
background: var(--penguin-beak, orange);
width: 16%;
height: 10%;
border-radius: 50%;
}
body {
background: #c6faf1;
}
.penguin * {
position: absolute;
}
</style>
<div class="penguin">
<div class="penguin-bottom">
<div class="right-hand"></div>
<div class="left-hand"></div>
<div class="right-feet"></div>
<div class="left-feet"></div>
</div>
<div class="penguin-top">
<div class="right-cheek"></div>
<div class="left-cheek"></div>
<div class="belly"></div>
<div class="right-eye">
<div class="sparkle"></div>
</div>
<div class="left-eye">
<div class="sparkle"></div>
</div>
<div class="blush-right"></div>
<div class="blush-left"></div>
<div class="beak-top"></div>
<div class="beak-bottom"></div>
</div>
</div>
```
# --solutions--
```html
<style>
.penguin-top {
background: var(--pengiun-skin, black);
}
.penguin-bottom {
background: var(--pengiun-skin, black);
}
</style>
```

View File

@ -0,0 +1,254 @@
---
id: 5a9d72a1424fe3d0e10cad15
title: 特定のエリアの変数を変更する
challengeType: 0
videoUrl: 'https://scrimba.com/c/cdRwbuW'
forumTopicId: 301085
dashedName: change-a-variable-for-a-specific-area
---
# --description--
`:root` で変数を作成すると、その変数の値がページ全体に設定されます。
これらの変数を特定の要素内で再度設定して上書きすることができます。
# --instructions--
`penguin` クラスの中で `--penguin-belly` の値を `white` に変更してください。
# --hints--
`penguin` クラスは `--penguin-belly` 変数に `white` を再代入しているはずです。
```js
assert(
code.match(/\.penguin\s*?{[\s\S]*--penguin-belly\s*?:\s*?white\s*?;[\s\S]*}/gi)
);
```
`penguin` クラスに `background-color` プロパティを含めないようにしてください。
```js
assert(
code.match(/^((?!background-color\s*?:\s*?)[\s\S])*$/g)
);
```
# --seed--
## --seed-contents--
```html
<style>
:root {
--penguin-skin: gray;
--penguin-belly: pink;
--penguin-beak: orange;
}
body {
background: var(--penguin-belly, #c6faf1);
}
.penguin {
/* Only change code below this line */
/* Only change code above this line */
position: relative;
margin: auto;
display: block;
margin-top: 5%;
width: 300px;
height: 300px;
}
.right-cheek {
top: 15%;
left: 35%;
background: var(--penguin-belly, pink);
width: 60%;
height: 70%;
border-radius: 70% 70% 60% 60%;
}
.left-cheek {
top: 15%;
left: 5%;
background: var(--penguin-belly, pink);
width: 60%;
height: 70%;
border-radius: 70% 70% 60% 60%;
}
.belly {
top: 60%;
left: 2.5%;
background: var(--penguin-belly, pink);
width: 95%;
height: 100%;
border-radius: 120% 120% 100% 100%;
}
.penguin-top {
top: 10%;
left: 25%;
background: var(--penguin-skin, gray);
width: 50%;
height: 45%;
border-radius: 70% 70% 60% 60%;
}
.penguin-bottom {
top: 40%;
left: 23.5%;
background: var(--penguin-skin, gray);
width: 53%;
height: 45%;
border-radius: 70% 70% 100% 100%;
}
.right-hand {
top: 0%;
left: -5%;
background: var(--penguin-skin, gray);
width: 30%;
height: 60%;
border-radius: 30% 30% 120% 30%;
transform: rotate(45deg);
z-index: -1;
}
.left-hand {
top: 0%;
left: 75%;
background: var(--penguin-skin, gray);
width: 30%;
height: 60%;
border-radius: 30% 30% 30% 120%;
transform: rotate(-45deg);
z-index: -1;
}
.right-feet {
top: 85%;
left: 60%;
background: var(--penguin-beak, orange);
width: 15%;
height: 30%;
border-radius: 50% 50% 50% 50%;
transform: rotate(-80deg);
z-index: -2222;
}
.left-feet {
top: 85%;
left: 25%;
background: var(--penguin-beak, orange);
width: 15%;
height: 30%;
border-radius: 50% 50% 50% 50%;
transform: rotate(80deg);
z-index: -2222;
}
.right-eye {
top: 45%;
left: 60%;
background: black;
width: 15%;
height: 17%;
border-radius: 50%;
}
.left-eye {
top: 45%;
left: 25%;
background: black;
width: 15%;
height: 17%;
border-radius: 50%;
}
.sparkle {
top: 25%;
left: 15%;
background: white;
width: 35%;
height: 35%;
border-radius: 50%;
}
.blush-right {
top: 65%;
left: 15%;
background: pink;
width: 15%;
height: 10%;
border-radius: 50%;
}
.blush-left {
top: 65%;
left: 70%;
background: pink;
width: 15%;
height: 10%;
border-radius: 50%;
}
.beak-top {
top: 60%;
left: 40%;
background: var(--penguin-beak, orange);
width: 20%;
height: 10%;
border-radius: 50%;
}
.beak-bottom {
top: 65%;
left: 42%;
background: var(--penguin-beak, orange);
width: 16%;
height: 10%;
border-radius: 50%;
}
.penguin * {
position: absolute;
}
</style>
<div class="penguin">
<div class="penguin-bottom">
<div class="right-hand"></div>
<div class="left-hand"></div>
<div class="right-feet"></div>
<div class="left-feet"></div>
</div>
<div class="penguin-top">
<div class="right-cheek"></div>
<div class="left-cheek"></div>
<div class="belly"></div>
<div class="right-eye">
<div class="sparkle"></div>
</div>
<div class="left-eye">
<div class="sparkle"></div>
</div>
<div class="blush-right"></div>
<div class="blush-left"></div>
<div class="beak-top"></div>
<div class="beak-bottom"></div>
</div>
</div>
```
# --solutions--
```html
<style>
.penguin {--penguin-belly: white;}
</style>
```

View File

@ -0,0 +1,122 @@
---
id: bad87fee1348bd9aedf08803
title: テキストの色を変更する
challengeType: 0
videoUrl: 'https://scrimba.com/c/cRkVmSm'
forumTopicId: 16775
dashedName: change-the-color-of-text
---
# --description--
では、テキストの色を変更してみましょう。
そのためには `h2` 要素の `style` を変更します。
要素のテキストの色を決めるプロパティは `color` スタイルプロパティです。
`h2` 要素の文字色を青に設定する方法は次のとおりです:
```html
<h2 style="color: blue;">CatPhotoApp</h2>
```
インラインの `style` 宣言は `;` で終わらせるのが良いと覚えておいてください。
# --instructions--
`h2` 要素のスタイルを変更して、テキストの色が赤になるようにしてください。
# --hints--
`h2` 要素は `style` 宣言を持つ必要があります。
```js
assert($('h2').attr('style'));
```
`h2` 要素の色は `red` に設定してください。
```js
assert($('h2')[0].style.color === 'red');
```
`style` の宣言は `;` で終わるようにしてください。
```js
assert($('h2').attr('style') && $('h2').attr('style').endsWith(';'));
```
# --seed--
## --seed-contents--
```html
<h2>CatPhotoApp</h2>
<main>
<p>Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
<div>
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
</div>
<form action="https://freecatphotoapp.com/submit-cat-photo">
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
<label><input type="checkbox" name="personality" checked> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Energetic</label><br>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
```
# --solutions--
```html
<h2 style="color: red;">CatPhotoApp</h2>
<main>
<p>Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
<div>
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
</div>
<form action="https://freecatphotoapp.com/submit-cat-photo">
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
<label><input type="checkbox" name="personality" checked> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Energetic</label><br>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
```

View File

@ -0,0 +1,119 @@
---
id: bad87fee1348bd9aedf08806
title: 要素のフォントサイズを変更する
challengeType: 0
videoUrl: 'https://scrimba.com/c/c3bvDc8'
forumTopicId: 16777
dashedName: change-the-font-size-of-an-element
---
# --description--
フォントサイズは次のように `font-size` という CSS プロパティで制御されます:
```css
h1 {
font-size: 30px;
}
```
# --instructions--
`red-text` クラスがあるのと同じ `<style>` タグの中に `p` 要素の項目を追加し、`font-size` を 16 ピクセル (`16px`) に設定してください。
# --hints--
`style` タグの中で `p` 要素の `font-size``16px` に設定してください。 ブラウザとテキストのズーム設定は 100% にする必要があります。
```js
assert(code.match(/p\s*{\s*font-size\s*:\s*16\s*px\s*;\s*}/i));
```
# --seed--
## --seed-contents--
```html
<style>
.red-text {
color: red;
}
</style>
<h2 class="red-text">CatPhotoApp</h2>
<main>
<p class="red-text">Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
<div>
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
</div>
<form action="https://freecatphotoapp.com/submit-cat-photo">
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
<label><input type="checkbox" name="personality" checked> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Energetic</label><br>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
```
# --solutions--
```html
<style>
.red-text {
color: red;
}
p {
font-size: 16px;
}
</style>
<h2 class="red-text">CatPhotoApp</h2>
<main>
<p class="red-text">Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
<div>
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
</div>
<form action="https://freecatphotoapp.com/submit-cat-photo">
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
<label><input type="checkbox" name="personality" checked> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Energetic</label><br>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
```

View File

@ -0,0 +1,241 @@
---
id: 5a9d726c424fe3d0e10cad11
title: カスタム CSS 変数を作成する
challengeType: 0
videoUrl: 'https://scrimba.com/c/cQd27Hr'
forumTopicId: 301086
dashedName: create-a-custom-css-variable
---
# --description--
CSS 変数を作成するには、2 つのハイフンで始まる名前を付けて、次のように値を代入します:
```css
--penguin-skin: gray;
```
これで `--penguin-skin` という名前の変数が作成され、`gray` の値が代入されます。 今では CSS の他の場所でその変数を使用して、他の要素の値を gray に変更できるようになりました。
# --instructions--
`penguin` クラスの中で、変数名 `--penguin-skin` を作成し、値を `gray` にしてください。
# --hints--
`penguin` クラスは `--penguin-skin` 変数を宣言し、`gray` を代入している必要があります。
```js
assert(
code.match(/\.penguin\s*\{[^{}]*?--penguin-skin\s*:\s*gr[ae]y\s*;[^{}]*?\}/gi)
);
```
# --seed--
## --seed-contents--
```html
<style>
.penguin {
/* Only change code below this line */
/* Only change code above this line */
position: relative;
margin: auto;
display: block;
margin-top: 5%;
width: 300px;
height: 300px;
}
.penguin-top {
top: 10%;
left: 25%;
background: black;
width: 50%;
height: 45%;
border-radius: 70% 70% 60% 60%;
}
.penguin-bottom {
top: 40%;
left: 23.5%;
background: black;
width: 53%;
height: 45%;
border-radius: 70% 70% 100% 100%;
}
.right-hand {
top: 0%;
left: -5%;
background: black;
width: 30%;
height: 60%;
border-radius: 30% 30% 120% 30%;
transform: rotate(45deg);
z-index: -1;
}
.left-hand {
top: 0%;
left: 75%;
background: black;
width: 30%;
height: 60%;
border-radius: 30% 30% 30% 120%;
transform: rotate(-45deg);
z-index: -1;
}
.right-cheek {
top: 15%;
left: 35%;
background: white;
width: 60%;
height: 70%;
border-radius: 70% 70% 60% 60%;
}
.left-cheek {
top: 15%;
left: 5%;
background: white;
width: 60%;
height: 70%;
border-radius: 70% 70% 60% 60%;
}
.belly {
top: 60%;
left: 2.5%;
background: white;
width: 95%;
height: 100%;
border-radius: 120% 120% 100% 100%;
}
.right-feet {
top: 85%;
left: 60%;
background: orange;
width: 15%;
height: 30%;
border-radius: 50% 50% 50% 50%;
transform: rotate(-80deg);
z-index: -2222;
}
.left-feet {
top: 85%;
left: 25%;
background: orange;
width: 15%;
height: 30%;
border-radius: 50% 50% 50% 50%;
transform: rotate(80deg);
z-index: -2222;
}
.right-eye {
top: 45%;
left: 60%;
background: black;
width: 15%;
height: 17%;
border-radius: 50%;
}
.left-eye {
top: 45%;
left: 25%;
background: black;
width: 15%;
height: 17%;
border-radius: 50%;
}
.sparkle {
top: 25%;
left: 15%;
background: white;
width: 35%;
height: 35%;
border-radius: 50%;
}
.blush-right {
top: 65%;
left: 15%;
background: pink;
width: 15%;
height: 10%;
border-radius: 50%;
}
.blush-left {
top: 65%;
left: 70%;
background: pink;
width: 15%;
height: 10%;
border-radius: 50%;
}
.beak-top {
top: 60%;
left: 40%;
background: orange;
width: 20%;
height: 10%;
border-radius: 50%;
}
.beak-bottom {
top: 65%;
left: 42%;
background: orange;
width: 16%;
height: 10%;
border-radius: 50%;
}
body {
background:#c6faf1;
}
.penguin * {
position: absolute;
}
</style>
<div class="penguin">
<div class="penguin-bottom">
<div class="right-hand"></div>
<div class="left-hand"></div>
<div class="right-feet"></div>
<div class="left-feet"></div>
</div>
<div class="penguin-top">
<div class="right-cheek"></div>
<div class="left-cheek"></div>
<div class="belly"></div>
<div class="right-eye">
<div class="sparkle"></div>
</div>
<div class="left-eye">
<div class="sparkle"></div>
</div>
<div class="blush-right"></div>
<div class="blush-left"></div>
<div class="beak-top"></div>
<div class="beak-bottom"></div>
</div>
</div>
```
# --solutions--
```html
<style>.penguin {--penguin-skin: gray;}</style>
```

View File

@ -0,0 +1,176 @@
---
id: bad87fed1348bd9aede07836
title: div 要素の背景色を設定する
challengeType: 0
videoUrl: 'https://scrimba.com/c/cdRKMCk'
forumTopicId: 18190
dashedName: give-a-background-color-to-a-div-element
---
# --description--
`background-color` プロパティで要素の背景色を設定できます。
例えば、要素の背景色を `green` にしたい場合は、`style` 要素にこのように設定します:
```css
.green-background {
background-color: green;
}
```
# --instructions--
`silver-background` というクラスを作成し、`background-color``silver` に指定してください。 このクラスを `div` 要素に割り当ててください。
# --hints--
`div` 要素にはクラス `silver-background` が必要です。
```js
assert($('div').hasClass('silver-background'));
```
`div` 要素の背景は銀色になるはずです。
```js
assert($('div').css('background-color') === 'rgb(192, 192, 192)');
```
`silver-background` という名前のクラスが `style` 要素内で定義され、`silver` の値が `background-color` プロパティに割り当てられている必要があります。
```js
assert(code.match(/\.silver-background\s*{\s*background-color\s*:\s*silver\s*;?\s*}/));
```
# --seed--
## --seed-contents--
```html
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
.red-text {
color: red;
}
h2 {
font-family: Lobster, monospace;
}
p {
font-size: 16px;
font-family: monospace;
}
.thick-green-border {
border-color: green;
border-width: 10px;
border-style: solid;
border-radius: 50%;
}
.smaller-image {
width: 100px;
}
</style>
<h2 class="red-text">CatPhotoApp</h2>
<main>
<p class="red-text">Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img class="smaller-image thick-green-border" src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
<div>
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
</div>
<form action="https://freecatphotoapp.com/submit-cat-photo">
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
<label><input type="checkbox" name="personality" checked> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Energetic</label><br>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
```
# --solutions--
```html
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
.red-text {
color: red;
}
h2 {
font-family: Lobster, monospace;
}
p {
font-size: 16px;
font-family: monospace;
}
.thick-green-border {
border-color: green;
border-width: 10px;
border-style: solid;
border-radius: 50%;
}
.smaller-image {
width: 100px;
}
.silver-background {
background-color: silver;
}
</style>
<h2 class="red-text">CatPhotoApp</h2>
<main>
<p class="red-text">Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img class="smaller-image thick-green-border" src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
<div class="silver-background">
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
</div>
<form action="https://freecatphotoapp.com/submit-cat-photo">
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
<label><input type="checkbox" name="personality" checked> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Energetic</label><br>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
```

View File

@ -0,0 +1,175 @@
---
id: bad87fee1348bd9aedf08807
title: Google フォントをインポートする
challengeType: 0
videoUrl: 'https://scrimba.com/c/cM9MRsJ'
forumTopicId: 18200
dashedName: import-a-google-font
---
# --description--
ほとんどのオペレーティングシステムで使われている一般的なフォントの他に、非標準のカスタム Web フォントを Web サイトに使うこともできます。 インターネット上には多くの Web フォントの提供元があります。 今回の例では Google Fonts ライブラリに焦点を当てます。
[Google Fonts](https://fonts.google.com/) は無料の Web フォントのライブラリで、フォントの URL を参照することであなたの CSS で使うことができるようになります。
では、Google フォントをインポートして適用してみましょう (もしあなたの国で Google がブロックされている場合は、このチャレンジを飛ばしてください) 。
Google フォントをインポートするには、Google Fonts のライブラリからフォントの URL をコピーしてあなたの HTML に貼り付けます。 このチャレンジでは、`Lobster` フォントをインポートしてみましょう。 そうするには、次のコードスニペットをコピーしてコードエディタの一番上に貼り付けます ( `style` 要素の前に):
```html
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
```
これで、あなたの CSS で `Lobster` フォントが使えるようになりました。下記の例の FAMILY_NAME の部分に `Lobster` を使うことができます:
```css
font-family: FAMILY_NAME, GENERIC_NAME;
```
GENERIC_NAME は必須ではなく、他の指定したフォントが使用できない場合に備えるフォールバックフォントです。 これは次のチャレンジで学習します。
ファミリー名は大文字と小文字が区別され、名前にスペースがある場合は引用符で囲む必要があります。 例えば、`"Open Sans"` フォントを使用するには引用符が必要ですが、`Lobster` フォントの場合は必要ではありません。
# --instructions--
あなたの Web ページに `Lobster` フォントをインポートしてください。 次に、要素セレクターを使用して `h2` 要素の `font-family``Lobster` に設定してください。
# --hints--
`Lobster` フォントをインポートする必要があります。
```js
assert($('link[href*="googleapis" i]').length);
```
`h2` 要素はフォント `Lobster` を使用する必要があります。
```js
assert(
$('h2')
.css('font-family')
.match(/lobster/i)
);
```
フォントを変更するために `h2` 要素セレクターのみを使用してください。
```js
assert(
/\s*[^\.]h2\s*\{\s*font-family\s*:\s*('|"|)Lobster\1\s*(,\s*('|"|)[a-z -]+\3\s*)?(;\s*\}|\})/gi.test(
code
)
);
```
`p` 要素は変わらず、フォント `monospace` を使用する必要があります。
```js
assert(
$('p')
.css('font-family')
.match(/monospace/i)
);
```
# --seed--
## --seed-contents--
```html
<style>
.red-text {
color: red;
}
p {
font-size: 16px;
font-family: monospace;
}
</style>
<h2 class="red-text">CatPhotoApp</h2>
<main>
<p class="red-text">Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
<div>
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
</div>
<form action="https://freecatphotoapp.com/submit-cat-photo">
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
<label><input type="checkbox" name="personality" checked> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Energetic</label><br>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
```
# --solutions--
```html
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
.red-text {
color: red;
}
p {
font-size: 16px;
font-family: monospace;
}
h2 {
font-family: Lobster;
}
</style>
<h2 class="red-text">CatPhotoApp</h2>
<main>
<p class="red-text">Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
<div>
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
</div>
<form action="https://freecatphotoapp.com/submit-cat-photo">
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
<label><input type="checkbox" name="personality" checked> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Energetic</label><br>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
```

View File

@ -0,0 +1,70 @@
---
id: 5b7d72c338cd7e35b63f3e14
title: ブラウザのフォールバックで互換性を向上させる
challengeType: 0
videoUrl: ''
forumTopicId: 301087
dashedName: improve-compatibility-with-browser-fallbacks
---
# --description--
CSS の作業をしているうちに、いつかブラウザの互換性の問題に遭遇するでしょう。 そのため、潜在的な問題を回避するためにブラウザのフォールバックを提供することが重要です。
ブラウザがウェブページの CSS を解析する際、認識できないプロパティやサポートされていないプロパティは無視されます。 例えば、CSS 変数を使用してサイトに背景色を割り当てている場合、Internet Explorer は CSS 変数をサポートしていないため、背景色を無視します。 その場合、ブラウザはそのプロパティに対して設定されている何らかの値を使用します。 そのプロパティに他の値の設定が見つからない場合はデフォルト値に戻ります。通常、これは理想的ではありません。
つまり、ブラウザのフォールバックを提供したい場合には、ある宣言の直前にもっと広くサポートされている値を提供することで簡単に実現できます。 そのようにすれば古いブラウザは何かフォールバックとして使用するものがある状態になり、同時に新しいブラウザはその後の宣言を解釈するようになります。
# --instructions--
`.red-box` クラスの背景色を設定するために変数が使用されているようです。 既存の宣言の直前にもう一つ `background` 宣言を追加し、その値を `red` に設定することで、ブラウザの互換性を改善しましょう。
# --hints--
`.red-box` のルール内において、既存の `background` 宣言の直前に、`background``red` に設定されたフォールバックを追加してください。
```js
assert(
code
.replace(/\s/g, '')
.match(
/\.red-box{background:(red|#ff0000|#f00|rgb\(255,0,0\)|rgb\(100%,0%,0%\)|hsl\(0,100%,50%\));background:var\(--red-color\);height:200px;width:200px;}/gi
)
);
```
# --seed--
## --seed-contents--
```html
<style>
:root {
--red-color: red;
}
.red-box {
background: var(--red-color);
height: 200px;
width:200px;
}
</style>
<div class="red-box"></div>
```
# --solutions--
```html
<style>
:root {
--red-color: red;
}
.red-box {
background: red;
background: var(--red-color);
height: 200px;
width:200px;
}
</style>
<div class="red-box"></div>
```

View File

@ -0,0 +1,244 @@
---
id: 5a9d7295424fe3d0e10cad14
title: CSS 変数を継承する
challengeType: 0
videoUrl: 'https://scrimba.com/c/cyLZZhZ'
forumTopicId: 301088
dashedName: inherit-css-variables
---
# --description--
変数を作成すると、その変数は作成したセレクターの中で使用できるようになります。 また、そのセレクターの子孫でも使用できます。 通常のプロパティと同様に CSS 変数が継承されるためにこのような動作になります。
継承を利用するために、CSS 変数は <dfn>:root</dfn> 要素で定義されることがよくあります。
`:root` は、通常はドキュメントのルート要素である `html` 要素に一致する、<dfn>疑似クラス</dfn> セレクターです。 `:root` 内で変数を作成することにより、その変数はグローバルで利用可能になり、スタイルシートの他のどのセレクターからでもアクセスできます。
# --instructions--
`:root` セレクターで `--penguin-belly` という名前の変数を定義し、`pink` の値を設定してください。 この変数が継承され、これを使用するすべての子要素がピンク色の背景になることを確認してください。
# --hints--
`--penguin-belly` 変数は `:root` 内で宣言し、値 `pink` を代入する必要があります。
```js
assert(
code.match(/:root\s*?{[\s\S]*--penguin-belly\s*?:\s*?pink\s*?;[\s\S]*}/gi)
);
```
# --seed--
## --seed-contents--
```html
<style>
:root {
/* Only change code below this line */
/* Only change code above this line */
}
body {
background: var(--penguin-belly, #c6faf1);
}
.penguin {
--penguin-skin: gray;
--penguin-beak: orange;
position: relative;
margin: auto;
display: block;
margin-top: 5%;
width: 300px;
height: 300px;
}
.right-cheek {
top: 15%;
left: 35%;
background: var(--penguin-belly, white);
width: 60%;
height: 70%;
border-radius: 70% 70% 60% 60%;
}
.left-cheek {
top: 15%;
left: 5%;
background: var(--penguin-belly, white);
width: 60%;
height: 70%;
border-radius: 70% 70% 60% 60%;
}
.belly {
top: 60%;
left: 2.5%;
background: var(--penguin-belly, white);
width: 95%;
height: 100%;
border-radius: 120% 120% 100% 100%;
}
.penguin-top {
top: 10%;
left: 25%;
background: var(--penguin-skin, gray);
width: 50%;
height: 45%;
border-radius: 70% 70% 60% 60%;
}
.penguin-bottom {
top: 40%;
left: 23.5%;
background: var(--penguin-skin, gray);
width: 53%;
height: 45%;
border-radius: 70% 70% 100% 100%;
}
.right-hand {
top: 0%;
left: -5%;
background: var(--penguin-skin, gray);
width: 30%;
height: 60%;
border-radius: 30% 30% 120% 30%;
transform: rotate(45deg);
z-index: -1;
}
.left-hand {
top: 0%;
left: 75%;
background: var(--penguin-skin, gray);
width: 30%;
height: 60%;
border-radius: 30% 30% 30% 120%;
transform: rotate(-45deg);
z-index: -1;
}
.right-feet {
top: 85%;
left: 60%;
background: var(--penguin-beak, orange);
width: 15%;
height: 30%;
border-radius: 50% 50% 50% 50%;
transform: rotate(-80deg);
z-index: -2222;
}
.left-feet {
top: 85%;
left: 25%;
background: var(--penguin-beak, orange);
width: 15%;
height: 30%;
border-radius: 50% 50% 50% 50%;
transform: rotate(80deg);
z-index: -2222;
}
.right-eye {
top: 45%;
left: 60%;
background: black;
width: 15%;
height: 17%;
border-radius: 50%;
}
.left-eye {
top: 45%;
left: 25%;
background: black;
width: 15%;
height: 17%;
border-radius: 50%;
}
.sparkle {
top: 25%;
left: 15%;
background: white;
width: 35%;
height: 35%;
border-radius: 50%;
}
.blush-right {
top: 65%;
left: 15%;
background: pink;
width: 15%;
height: 10%;
border-radius: 50%;
}
.blush-left {
top: 65%;
left: 70%;
background: pink;
width: 15%;
height: 10%;
border-radius: 50%;
}
.beak-top {
top: 60%;
left: 40%;
background: var(--penguin-beak, orange);
width: 20%;
height: 10%;
border-radius: 50%;
}
.beak-bottom {
top: 65%;
left: 42%;
background: var(--penguin-beak, orange);
width: 16%;
height: 10%;
border-radius: 50%;
}
.penguin * {
position: absolute;
}
</style>
<div class="penguin">
<div class="penguin-bottom">
<div class="right-hand"></div>
<div class="left-hand"></div>
<div class="right-feet"></div>
<div class="left-feet"></div>
</div>
<div class="penguin-top">
<div class="right-cheek"></div>
<div class="left-cheek"></div>
<div class="belly"></div>
<div class="right-eye">
<div class="sparkle"></div>
</div>
<div class="left-eye">
<div class="sparkle"></div>
</div>
<div class="blush-right"></div>
<div class="blush-left"></div>
<div class="beak-top"></div>
<div class="beak-bottom"></div>
</div>
</div>
```
# --solutions--
```html
<style>:root {--penguin-belly: pink;}</style>
```

View File

@ -0,0 +1,111 @@
---
id: bad87fee1348bd9aedf08746
title: Body 要素からスタイルを継承する
challengeType: 0
videoUrl: 'https://scrimba.com/c/c9bmdtR'
forumTopicId: 18204
dashedName: inherit-styles-from-the-body-element
---
# --description--
すべての HTML ページに `body` 要素があることと、`body` 要素も CSS でスタイルを変更できることが確認できました。
`body` 要素も他の HTML 要素と同じようにスタイルを変更できることと、他のすべての要素は `body` 要素のスタイルを継承することを覚えておきましょう。
# --instructions--
まず、`Hello World` というテキストを持つ `h1` 要素を作成します。
次に、`body` 要素のスタイル宣言に `color: green;` を追加して、あなたのページにあるすべての要素の文字色を `green` にしましょう。
最後に、`body` 要素のスタイル宣言に `font-family: monospace;` を追加して、`body` 要素の font-family を `monospace` にしましょう。
# --hints--
`h1` 要素を作成してください。
```js
assert($('h1').length > 0);
```
`h1` 要素のテキストは `Hello World` でなければなりません。
```js
assert(
$('h1').length > 0 &&
$('h1')
.text()
.match(/hello world/i)
);
```
`h1` 要素には終了タグが必要です。
```js
assert(
code.match(/<\/h1>/g) &&
code.match(/<h1/g) &&
code.match(/<\/h1>/g).length === code.match(/<h1/g).length
);
```
`body` 要素の `color` プロパティを `green` に設定してください。
```js
assert($('body').css('color') === 'rgb(0, 128, 0)');
```
`body` 要素の `font-family` プロパティを `monospace` に設定してください。
```js
assert(
$('body')
.css('font-family')
.match(/monospace/i)
);
```
`h1` 要素は、`body` 要素から `monospace` フォントを継承しているはずです。
```js
assert(
$('h1').length > 0 &&
$('h1')
.css('font-family')
.match(/monospace/i)
);
```
`h1` 要素は、`body` 要素から緑の文字色を継承しているはずです。
```js
assert($('h1').length > 0 && $('h1').css('color') === 'rgb(0, 128, 0)');
```
# --seed--
## --seed-contents--
```html
<style>
body {
background-color: black;
}
</style>
```
# --solutions--
```html
<style>
body {
background-color: black;
font-family: monospace;
color: green;
}
</style>
<h1>Hello World!</h1>
```

View File

@ -0,0 +1,159 @@
---
id: bad87fee1348bd9aedf08815
title: border-radius で丸い画像を作成する
challengeType: 0
videoUrl: 'https://scrimba.com/c/c2MvrcB'
forumTopicId: 18229
dashedName: make-circular-images-with-a-border-radius
---
# --description--
ピクセルの他に、パーセンテージを使用して `border-radius` を指定することもできます。
# --instructions--
猫の写真の `border-radius``50%` にしましょう。
# --hints--
画像の境界線の角の半径は `50%` に設定されており、完全に丸くなるはずです。
```js
assert(parseInt($('img').css('border-top-left-radius')) > 48);
```
`border-radius` の値は `50%` のパーセンテージ値を使用する必要があります。
```js
assert(code.match(/50%/g));
```
# --seed--
## --seed-contents--
```html
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
.red-text {
color: red;
}
h2 {
font-family: Lobster, monospace;
}
p {
font-size: 16px;
font-family: monospace;
}
.thick-green-border {
border-color: green;
border-width: 10px;
border-style: solid;
border-radius: 10px;
}
.smaller-image {
width: 100px;
}
</style>
<h2 class="red-text">CatPhotoApp</h2>
<main>
<p class="red-text">Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img class="smaller-image thick-green-border" src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
<div>
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
</div>
<form action="https://freecatphotoapp.com/submit-cat-photo">
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
<label><input type="checkbox" name="personality" checked> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Energetic</label><br>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
```
# --solutions--
```html
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
.red-text {
color: red;
}
h2 {
font-family: Lobster, monospace;
}
p {
font-size: 16px;
font-family: monospace;
}
.thick-green-border {
border-color: green;
border-width: 10px;
border-style: solid;
border-radius: 10px;
}
.smaller-image {
width: 100px;
border-radius: 50%;
}
</style>
<h2 class="red-text">CatPhotoApp</h2>
<main>
<p class="red-text">Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img class="smaller-image thick-green-border" src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
<div>
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
</div>
<form action="https://freecatphotoapp.com/submit-cat-photo">
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
<label><input type="checkbox" name="personality" checked> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Energetic</label><br>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
```

View File

@ -0,0 +1,114 @@
---
id: bad87fee1348bd9aedf07756
title: Important で他のすべてのスタイルをオーバーライドする
challengeType: 0
videoUrl: 'https://scrimba.com/c/cm24rcp'
forumTopicId: 18249
dashedName: override-all-other-styles-by-using-important
---
# --description--
おめでとう! インラインスタイルが `style` 要素内のすべての CSS 宣言をオーバーライドすることを証明しました。
でも待ってください。 CSS をオーバーライドする方法が最後にもう 1 つあります。 これは最も強力な方法です。 でもその前に、そもそもなぜ CSS をオーバーライドしたいのかについて話しましょう。
多くの状況で、あなたは CSS ライブラリを使用することがあるでしょう。 これらはあなたが書いた CSS を思いがけずオーバーライドする可能性があります。 特定の CSS が、ある要素に必ず適用される必要がある場合、`!important` を使用できます。
`pink-text` のクラス宣言に戻りましょう。 `pink-text` クラスは後続のクラス宣言、id 宣言、およびインラインスタイルによってオーバーライドされたことを思い出してください。
# --instructions--
キーワード `!important` を pink-text の文字色の宣言に追加して、`h1` 要素が 100 必ずピンクで表示されるようにしましょう。
このやり方の例は次のようになります:
```css
color: red !important;
```
# --hints--
`h1` 要素にはクラス `pink-text` が必要です。
```js
assert($('h1').hasClass('pink-text'));
```
`h1` 要素にはクラス `blue-text` が必要です。
```js
assert($('h1').hasClass('blue-text'));
```
`h1` 要素には `orange-text` という `id` が必要です。
```js
assert($('h1').attr('id') === 'orange-text');
```
`h1` 要素にインラインスタイルで `color: white` が指定されている必要があります。
```js
assert(code.match(/<h1.*style/gi) && code.match(/<h1.*style.*color\s*?:/gi));
```
`pink-text` クラス宣言は、他のすべての宣言をオーバーライドするために `!important` キーワードを持つ必要があります。
```js
assert(
code.match(/\.pink-text\s*?\{[\s\S]*?color:.*pink.*!important\s*;?[^\.]*\}/g)
);
```
`h1` 要素がピンクで表示されている必要があります。
```js
assert($('h1').css('color') === 'rgb(255, 192, 203)');
```
# --seed--
## --seed-contents--
```html
<style>
body {
background-color: black;
font-family: monospace;
color: green;
}
#orange-text {
color: orange;
}
.pink-text {
color: pink;
}
.blue-text {
color: blue;
}
</style>
<h1 id="orange-text" class="pink-text blue-text" style="color: white">Hello World!</h1>
```
# --solutions--
```html
<style>
body {
background-color: black;
font-family: monospace;
color: green;
}
#orange-text {
color: orange;
}
.pink-text {
color: pink !important;
}
.blue-text {
color: blue;
}
</style>
<h1 id="orange-text" class="pink-text blue-text" style="color: white">Hello World!</h1>
```

View File

@ -0,0 +1,123 @@
---
id: bad87fee1348bd8aedf06756
title: クラス宣言を ID 属性のスタイルでオーバーライドする
challengeType: 0
videoUrl: 'https://scrimba.com/c/cRkpDhB'
forumTopicId: 18251
dashedName: override-class-declarations-by-styling-id-attributes
---
# --description--
私たちは、ブラウザが CSS を上から下へ宣言の順に読み込むことを証明しました。 つまり、競合が発生した場合、ブラウザは後に来た CSS 宣言を使用します。 `h1` 要素のクラス属性で `blue-text``pink-text` の前に置いたとしても、使われた順番ではなく宣言の順番が見られることに注目してください。
これで終わりではありません。 CSS をオーバーライドする方法は他にもあります。 id 属性を覚えていますか?
`h1` 要素に id を追加してその id を使ってスタイルを変更することで、`pink-text``blue-text` のクラスをオーバーライドして `h1` 要素をオレンジにしてみましょう。
# --instructions--
`h1` 要素に `orange-text` という `id` 属性を追加してください。 id スタイルは以下のようになります:
```html
<h1 id="orange-text">
```
`h1` 要素の `blue-text``pink-text` のクラスはそのままにしてください。
`style` 要素内に id `orange-text` 用の CSS 宣言を作成します。 こちらの例と似たような書き方になるでしょう:
```css
#brown-text {
color: brown;
}
```
**注:** この CSS の宣言は `pink-text` クラスの上下どちらにあっても差し支えありません。 `id` 属性は常に優先されるためです。
# --hints--
`h1` 要素にはクラス `pink-text` が必要です。
```js
assert($('h1').hasClass('pink-text'));
```
`h1` 要素にはクラス `blue-text` が必要です。
```js
assert($('h1').hasClass('blue-text'));
```
`h1` 要素には id `orange-text` が必要です。
```js
assert($('h1').attr('id') === 'orange-text');
```
`h1` 要素は 1 つだけ必要です。
```js
assert($('h1').length === 1);
```
`orange-text` の id には CSS 宣言が必要です。
```js
assert(code.match(/#orange-text\s*{/gi));
```
`h1` には `style` 属性を設定してはいけません。
```js
assert(!code.match(/<h1.*style.*>/gi));
```
`h1` 要素がオレンジで表示されている必要があります。
```js
assert($('h1').css('color') === 'rgb(255, 165, 0)');
```
# --seed--
## --seed-contents--
```html
<style>
body {
background-color: black;
font-family: monospace;
color: green;
}
.pink-text {
color: pink;
}
.blue-text {
color: blue;
}
</style>
<h1 class="pink-text blue-text">Hello World!</h1>
```
# --solutions--
```html
<style>
body {
background-color: black;
font-family: monospace;
color: green;
}
.pink-text {
color: pink;
}
.blue-text {
color: blue;
}
#orange-text {
color: orange;
}
</style>
<h1 id="orange-text" class="pink-text blue-text">Hello World!</h1>
```

View File

@ -0,0 +1,102 @@
---
id: bad87fee1348bd9aedf06756
title: インラインスタイルでクラス宣言をオーバーライドする
challengeType: 0
videoUrl: 'https://scrimba.com/c/cGJDRha'
forumTopicId: 18252
dashedName: override-class-declarations-with-inline-styles
---
# --description--
id 宣言は `style` 要素の CSS で宣言されている場所に関係なく、クラス宣言をオーバーライドすることを証明しました。
CSS をオーバーライドする方法は他にもあります。 インラインスタイルを覚えていますか?
# --instructions--
インラインスタイルを使用して、`h1` 要素を白くしてみましょう。 インラインスタイルは以下のような書き方です:
```html
<h1 style="color: green;">
```
`h1` 要素の `blue-text``pink-text` のクラスはそのままにしてください。
# --hints--
`h1` 要素にはクラス `pink-text` が必要です。
```js
assert($('h1').hasClass('pink-text'));
```
`h1` 要素にはクラス `blue-text` が必要です。
```js
assert($('h1').hasClass('blue-text'));
```
`h1` 要素には id `orange-text` が必要です。
```js
assert($('h1').attr('id') === 'orange-text');
```
`h1` 要素にインラインスタイルが必要です。
```js
assert(document.querySelector('h1[style]'));
```
`h1` 要素が白で表示されている必要があります。
```js
assert($('h1').css('color') === 'rgb(255, 255, 255)');
```
# --seed--
## --seed-contents--
```html
<style>
body {
background-color: black;
font-family: monospace;
color: green;
}
#orange-text {
color: orange;
}
.pink-text {
color: pink;
}
.blue-text {
color: blue;
}
</style>
<h1 id="orange-text" class="pink-text blue-text">Hello World!</h1>
```
# --solutions--
```html
<style>
body {
background-color: black;
font-family: monospace;
color: green;
}
#orange-text {
color: orange;
}
.pink-text {
color: pink;
}
.blue-text {
color: blue;
}
</style>
<h1 id="orange-text" class="pink-text blue-text" style="color: white">Hello World!</h1>
```

View File

@ -0,0 +1,94 @@
---
id: bad87fee1348bd9aedf04756
title: 後続の CSS でスタイルをオーバーライドする
challengeType: 0
videoUrl: 'https://scrimba.com/c/cGJDQug'
forumTopicId: 18253
dashedName: override-styles-in-subsequent-css
---
# --description--
`pink-text` クラスが `body` 要素の CSS 宣言より優先されました!
私達の作成したクラスが `body` 要素の CSS をオーバーライドすることを証明しました。 次の論理的な疑問は、`pink-text` クラスをオーバーライドするにはどうすればいいのかということです。
# --instructions--
要素に青の文字色を設定する `blue-text` という CSS クラスを追加してください。 必ず `pink-text` クラスの宣言より下に追加してください。
`h1` 要素に対し、`pink-text` クラスに加えて `blue-text` クラスも適用して、どちらが勝つか見てみましょう。
1 つの HTML 要素に複数のクラス属性を適用するには、以下のようにスペースで区切ります:
```html
class="class1 class2"
```
**注:** HTML 要素にクラスを並べる順番は関係ありません。
しかし、`<style>` セクション内での `class` 宣言の順番が重要になります。 2 番目の宣言は常に最初の宣言よりも優先されます。 `.blue-text` は 2 番目に宣言されているため、`.pink-text` の属性をオーバーライドします。
# --hints--
`h1` 要素にはクラス `pink-text` が必要です。
```js
assert($('h1').hasClass('pink-text'));
```
`h1` 要素にはクラス `blue-text` が必要です。
```js
assert($('h1').hasClass('blue-text'));
```
`blue-text``pink-text` の両方が同じ `h1` 要素に適用されている必要があります。
```js
assert($('.pink-text').hasClass('blue-text'));
```
`h1` 要素が青で表示されている必要があります。
```js
assert($('h1').css('color') === 'rgb(0, 0, 255)');
```
# --seed--
## --seed-contents--
```html
<style>
body {
background-color: black;
font-family: monospace;
color: green;
}
.pink-text {
color: pink;
}
</style>
<h1 class="pink-text">Hello World!</h1>
```
# --solutions--
```html
<style>
body {
background-color: black;
font-family: monospace;
color: green;
}
.pink-text {
color: pink;
}
.blue-text {
color: blue;
}
</style>
<h1 class="pink-text blue-text">Hello World!</h1>
```

View File

@ -0,0 +1,73 @@
---
id: bad87fee1348bd9aedf08756
title: スタイルを別のスタイルより優先する
challengeType: 0
videoUrl: 'https://scrimba.com/c/cZ8wnHv'
forumTopicId: 18258
dashedName: prioritize-one-style-over-another
---
# --description--
HTML 要素が、互いに競合する複数のスタイル指定を受け取ることがあります。
例えば、`h1` 要素を同時に緑とピンクの両方にすることはできません。
テキストをピンク色にするクラスを作成し、要素に適用するとどうなるか見てみましょう。 私達のクラスは `body` 要素の `color: green;` という CSS プロパティを*オーバーライド* (無視) するでしょうか?
# --instructions--
要素にピンクの文字色を設定する `pink-text` という CSS クラスを作成してください。
`h1` 要素に `pink-text` クラスを適用してください。
# --hints--
`h1` 要素にはクラス `pink-text` が必要です。
```js
assert($('h1').hasClass('pink-text'));
```
`<style>` 内に `color` を変更する `pink-text` CSS クラスが必要です。
```js
assert(code.match(/\.pink-text\s*\{\s*color\s*:\s*.+\s*;?\s*\}/g));
```
`h1` 要素がピンクで表示されている必要があります。
```js
assert($('h1').css('color') === 'rgb(255, 192, 203)');
```
# --seed--
## --seed-contents--
```html
<style>
body {
background-color: black;
font-family: monospace;
color: green;
}
</style>
<h1>Hello World!</h1>
```
# --solutions--
```html
<style>
body {
background-color: black;
font-family: monospace;
color: green;
}
.pink-text {
color: pink;
}
</style>
<h1 class="pink-text">Hello World!</h1>
```

View File

@ -0,0 +1,132 @@
---
id: bad87fee1348bd9aede08807
title: 要素のフォントファミリーを設定する
challengeType: 0
videoUrl: 'https://scrimba.com/c/c3bvpCg'
forumTopicId: 18278
dashedName: set-the-font-family-of-an-element
---
# --description--
`font-family` プロパティを使用して、要素がどのフォントを使用するかを設定できます。
例えば、`h2` 要素のフォントを `sans-serif` に設定したい場合は、次の CSS を使用します:
```css
h2 {
font-family: sans-serif;
}
```
# --instructions--
すべての `p` 要素に `monospace` フォントを使用するように設定してください。
# --hints--
`p` 要素はフォント `monospace` を使用する必要があります。
```js
assert(
$('p')
.not('.red-text')
.css('font-family')
.match(/monospace/i)
);
```
# --seed--
## --seed-contents--
```html
<style>
.red-text {
color: red;
}
p {
font-size: 16px;
}
</style>
<h2 class="red-text">CatPhotoApp</h2>
<main>
<p class="red-text">Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
<div>
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
</div>
<form action="https://freecatphotoapp.com/submit-cat-photo">
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
<label><input type="checkbox" name="personality" checked> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Energetic</label><br>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
```
# --solutions--
```html
<style>
.red-text {
color: red;
}
p {
font-size: 16px;
font-family: monospace;
}
</style>
<h2 class="red-text">CatPhotoApp</h2>
<main>
<p class="red-text">Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
<div>
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
</div>
<form action="https://freecatphotoapp.com/submit-cat-photo">
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
<label><input type="checkbox" name="personality" checked> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Energetic</label><br>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
```

View File

@ -0,0 +1,170 @@
---
id: bad87eee1348bd9aede07836
title: 要素の id を設定する
challengeType: 0
videoUrl: 'https://scrimba.com/c/cN6MEc2'
forumTopicId: 18279
dashedName: set-the-id-of-an-element
---
# --description--
クラスに加えて、各 HTML 要素は `id` 属性を持つこともできます。
`id` 属性を使用するいくつかの利点があります: 単一の要素のスタイルを指定するために `id` を使用することができます。また、JavaScript で特定の要素を選択して変更できることも後ほど学習します。
`id` 属性は一意でなければなりません。 ブラウザはこの制限を強制しませんが、ベストプラクティスとして広く受け入れられています。 したがって、複数の要素に同じ `id` 属性を与えないようにしてください。
`h2` 要素に `cat-photo-app` という id を与える例を以下に示します:
```html
<h2 id="cat-photo-app">
```
# --instructions--
`form` 要素に `cat-photo-form` という id を設定してください。
# --hints--
`form` 要素は、`cat-photo-form` という id を持つ必要があります。
```js
assert($('form').attr('id') === 'cat-photo-form');
```
# --seed--
## --seed-contents--
```html
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
.red-text {
color: red;
}
h2 {
font-family: Lobster, monospace;
}
p {
font-size: 16px;
font-family: monospace;
}
.thick-green-border {
border-color: green;
border-width: 10px;
border-style: solid;
border-radius: 50%;
}
.smaller-image {
width: 100px;
}
.silver-background {
background-color: silver;
}
</style>
<h2 class="red-text">CatPhotoApp</h2>
<main>
<p class="red-text">Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img class="smaller-image thick-green-border" src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
<div class="silver-background">
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
</div>
<form action="https://freecatphotoapp.com/submit-cat-photo">
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
<label><input type="checkbox" name="personality" checked> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Energetic</label><br>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
```
# --solutions--
```html
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
.red-text {
color: red;
}
h2 {
font-family: Lobster, monospace;
}
p {
font-size: 16px;
font-family: monospace;
}
.thick-green-border {
border-color: green;
border-width: 10px;
border-style: solid;
border-radius: 50%;
}
.smaller-image {
width: 100px;
}
.silver-background {
background-color: silver;
}
</style>
<h2 class="red-text">CatPhotoApp</h2>
<main>
<p class="red-text">Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img class="smaller-image thick-green-border" src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
<div class="silver-background">
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
</div>
<form action="https://freecatphotoapp.com/submit-cat-photo" id="cat-photo-form">
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
<label><input type="checkbox" name="personality" checked> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Energetic</label><br>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
```

View File

@ -0,0 +1,155 @@
---
id: bad87fee1348bd9acdf08812
title: 画像のサイズを変更する
challengeType: 0
forumTopicId: 18282
dashedName: size-your-images
---
# --description--
CSS には要素の幅を制御する `width` というプロパティがあります。 フォントと同じように、`px` (ピクセル) を使用して画像の幅を指定します。
例えば、HTML 要素に 500 ピクセルの幅を与える `larger-image` という CSS クラスを作成したい場合、次のようにします:
```html
<style>
.larger-image {
width: 500px;
}
</style>
```
# --instructions--
`smaller-image` というクラスを作成し、それを使用して画像のサイズを幅 100 ピクセルに変更してください。
# --hints--
`img` 要素にはクラス `smaller-image` が必要です。
```js
assert(
$("img[src='https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg']").attr('class')
.trim().split(/\s+/g).includes('smaller-image')
);
```
画像の幅が 100 ピクセルになるようにしてください。
```js
assert(
$('img').width() < 200 &&
code.match(/\.smaller-image\s*{\s*width\s*:\s*100px\s*(;\s*}|})/i)
);
```
# --seed--
## --seed-contents--
```html
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
.red-text {
color: red;
}
h2 {
font-family: Lobster, monospace;
}
p {
font-size: 16px;
font-family: monospace;
}
</style>
<h2 class="red-text">CatPhotoApp</h2>
<main>
<p class="red-text">Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
<div>
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
</div>
<form action="https://freecatphotoapp.com/submit-cat-photo">
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
<label><input type="checkbox" name="personality" checked> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Energetic</label><br>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
```
# --solutions--
```html
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
.red-text {
color: red;
}
h2 {
font-family: Lobster, monospace;
}
p {
font-size: 16px;
font-family: monospace;
}
.smaller-image {
width: 100px;
}
</style>
<h2 class="red-text">CatPhotoApp</h2>
<main>
<p class="red-text">Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img class="smaller-image" src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
<div>
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
</div>
<form action="https://freecatphotoapp.com/submit-cat-photo">
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
<label><input type="checkbox" name="personality" checked> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Energetic</label><br>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
```

View File

@ -0,0 +1,172 @@
---
id: bad87fee1348bd9aedf08808
title: 代替フォントを指定する
challengeType: 0
videoUrl: 'https://scrimba.com/c/cpVKBfQ'
forumTopicId: 18304
dashedName: specify-how-fonts-should-degrade
---
# --description--
すべてのブラウザで利用可能なデフォルトのフォントがいくつかあります。 この総称フォントファミリには、`monospace``serif``sans-serif` などがあります。
あるフォントが利用できない場合は、別のフォントへ「降格」するようにブラウザに伝えることができます。
例えば、ある要素に `Helvetica` フォントを使いたいが、`Helvetica` が利用できない場合には代わりに `sans-serif` フォントを使うようにしたいという場合、それを以下のように指定することができます:
```css
p {
font-family: Helvetica, sans-serif;
}
```
総称フォントファミリ名では大文字と小文字は区別されません。 また、これらは CSS キーワードであるため、引用符は必要ありません。
# --instructions--
始めに、`h2` 要素に `monospace` フォントを適用し、`Lobster``monospace` の 2 つのフォントが指定された状態にしてください。
ひとつ前のチャレンジでは、`link` タグを使用して `Lobster` フォントをインポートしました。 ここでその `Lobster` フォントを Google Fonts からインポートするコードをコメントアウトして (以前学習した HTML コメントを使いましょう)、利用できないようにしてみましょう。 `h2` 要素が `monospace` フォントに降格されることを確認してください。
**注:** もし `Lobster` フォントがあなたのコンピュータにインストールされている場合、ブラウザはフォントを見つけることができるので、この降格の動作を見ることはできません。
# --hints--
h2 要素はフォント `Lobster` を使用する必要があります。
```js
assert(
$('h2')
.css('font-family')
.match(/^"?lobster/i)
);
```
h2 要素は、`Lobster` が利用できない場合 `monospace` フォントで表示されるはずです。
```js
assert(
/\s*h2\s*\{\s*font-family\s*\:\s*(\'|"|)Lobster\1\s*,\s*monospace\s*;?\s*\}/gi.test(
code
)
);
```
`Lobster` フォントを取得する Google への呼び出しを、その前に `<!--` を置いてコメントアウトしてください。
```js
assert(new RegExp('<!--[^fc]', 'gi').test(code));
```
`-->` を追加してコメントを閉じる必要があります。
```js
assert(new RegExp('[^fc]-->', 'gi').test(code));
```
# --seed--
## --seed-contents--
```html
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
.red-text {
color: red;
}
h2 {
font-family: Lobster;
}
p {
font-size: 16px;
font-family: monospace;
}
</style>
<h2 class="red-text">CatPhotoApp</h2>
<main>
<p class="red-text">Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
<div>
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
</div>
<form action="https://freecatphotoapp.com/submit-cat-photo">
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
<label><input type="checkbox" name="personality" checked> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Energetic</label><br>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
```
# --solutions--
```html
<!--<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">-->
<style>
.red-text {
color: red;
}
h2 {
font-family: Lobster, monospace;
}
p {
font-size: 16px;
font-family: monospace;
}
</style>
<h2 class="red-text">CatPhotoApp</h2>
<main>
<p class="red-text">Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
<div>
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
</div>
<form action="https://freecatphotoapp.com/submit-cat-photo">
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
<label><input type="checkbox" name="personality" checked> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Energetic</label><br>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
```

View File

@ -0,0 +1,133 @@
---
id: bad87fee1348bd9aefe08806
title: 1 つの CSS クラスで複数の要素のスタイルを指定する
challengeType: 0
videoUrl: 'https://scrimba.com/c/cRkVbsQ'
forumTopicId: 18311
dashedName: style-multiple-elements-with-a-css-class
---
# --description--
クラスを使うと、同じ CSS スタイルを複数の HTML 要素に適用することができます。 最初の `p` 要素に `red-text` クラスを適用することで、この動作を確認できます。
# --hints--
`h2` 要素が赤で表示されている必要があります。
```js
assert($('h2').css('color') === 'rgb(255, 0, 0)');
```
`h2` 要素にはクラス `red-text` が必要です。
```js
assert($('h2').hasClass('red-text'));
```
最初の `p` 要素が赤で表示されている必要があります。
```js
assert($('p:eq(0)').css('color') === 'rgb(255, 0, 0)');
```
2 番目と 3 番目の `p` 要素は赤で表示されてはいけません。
```js
assert(
!($('p:eq(1)').css('color') === 'rgb(255, 0, 0)') &&
!($('p:eq(2)').css('color') === 'rgb(255, 0, 0)')
);
```
最初の `p` 要素にはクラス `red-text` が必要です。
```js
assert($('p:eq(0)').hasClass('red-text'));
```
# --seed--
## --seed-contents--
```html
<style>
.red-text {
color: red;
}
</style>
<h2 class="red-text">CatPhotoApp</h2>
<main>
<p>Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
<div>
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
</div>
<form action="https://freecatphotoapp.com/submit-cat-photo">
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
<label><input type="checkbox" name="personality" checked> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Energetic</label><br>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
```
# --solutions--
```html
<style>
.red-text {
color: red;
}
</style>
<h2 class="red-text">CatPhotoApp</h2>
<main>
<p class="red-text">Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
<div>
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
</div>
<form action="https://freecatphotoapp.com/submit-cat-photo">
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
<label><input type="checkbox" name="personality" checked> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Energetic</label><br>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
```

View File

@ -0,0 +1,70 @@
---
id: bad87fee1348bd9aedf08736
title: HTML の Body 要素のスタイルを変更する
challengeType: 0
videoUrl: 'https://scrimba.com/c/cB77PHW'
forumTopicId: 18313
dashedName: style-the-html-body-element
---
# --description--
ここからは新しく CSS の継承についての話を始めましょう。
すべての HTML ページには `body` 要素があります。
# --instructions--
`background-color` を黒に設定すれば、ここに `body` 要素があることが確認できます。
`style` 要素に以下を追加することでそれができます:
```css
body {
background-color: black;
}
```
# --hints--
`body` 要素は `background-color` を黒に設定されている必要があります。
```js
assert($('body').css('background-color') === 'rgb(0, 0, 0)');
```
CSS ルールは、開始と終了両方の波括弧で適切にフォーマットされている必要があります。
```js
assert(
code.match(/<style>\s*body\s*\{\s*background.*\s*:\s*.*;\s*\}\s*<\/style>/i)
);
```
CSS ルールはセミコロンで終わる必要があります。
```js
assert(
code.match(/<style>\s*body\s*\{\s*background.*\s*:\s*.*;\s*\}\s*<\/style>/i)
);
```
# --seed--
## --seed-contents--
```html
<style>
</style>
```
# --solutions--
```html
<style>
body {
background-color: black;
}
</style>
```

View File

@ -0,0 +1,123 @@
---
id: bad82fee1322bd9aedf08721
title: 絶対単位と相対単位を理解する
challengeType: 0
videoUrl: 'https://scrimba.com/c/cN66JSL'
forumTopicId: 301089
dashedName: understand-absolute-versus-relative-units
---
# --description--
ここまでのいくつかのチャレンジでは、要素のマージンやパディングを設定するのにピクセル (`px`) を使いました。 ピクセルは長さの単位の一種で、ブラウザにアイテムのサイズやスペースを指示します。 `px` の他にも CSS で使用できる長さの単位は数多くあります。
長さの単位の主な 2 つの分類は絶対単位と相対単位です。 絶対単位は物理的な長さの単位に対応します。 例えば、`in``mm` はそれぞれインチとミリメートルを表します。 絶対単位はおおよそ画面上の実際の長さですが、画面の解像度によっていくらかの違いがあります。
`em``rem` などの相対単位は、他の長さの値に比例します。 例えば、`em` は要素のフォントのサイズに基づきます。 em を `font-size` プロパティ自体を設定するために使用する場合は、親要素の `font-size` に対して相対的になります。
**注:** ビューポートのサイズと対応する相対単位もいくつかあります。 これらはレスポンシブウェブデザイン原則のセクションで説明します。
# --instructions--
`red-box` クラスを持つ要素に `padding` プロパティを追加し、`1.5em` に設定してください。
# --hints--
`red-box` クラスが `padding` プロパティを持つようにしてください。
```js
assert(
$('.red-box').css('padding-top') != '0px' &&
$('.red-box').css('padding-right') != '0px' &&
$('.red-box').css('padding-bottom') != '0px' &&
$('.red-box').css('padding-left') != '0px'
);
```
`red-box` クラスは、要素に 1.5em の `padding` を与える必要があります。
```js
assert(code.match(/\.red-box\s*?{[\s\S]*padding\s*:\s*?1\.5em/gi));
```
# --seed--
## --seed-contents--
```html
<style>
.injected-text {
margin-bottom: -25px;
text-align: center;
}
.box {
border-style: solid;
border-color: black;
border-width: 5px;
text-align: center;
}
.yellow-box {
background-color: yellow;
padding: 20px 40px 20px 40px;
}
.red-box {
background-color: red;
margin: 20px 40px 20px 40px;
}
.green-box {
background-color: green;
margin: 20px 40px 20px 40px;
}
</style>
<h5 class="injected-text">margin</h5>
<div class="box yellow-box">
<h5 class="box red-box">padding</h5>
<h5 class="box green-box">padding</h5>
</div>
```
# --solutions--
```html
<style>
.injected-text {
margin-bottom: -25px;
text-align: center;
}
.box {
border-style: solid;
border-color: black;
border-width: 5px;
text-align: center;
}
.yellow-box {
background-color: yellow;
padding: 20px 40px 20px 40px;
}
.red-box {
background-color: red;
margin: 20px 40px 20px 40px;
padding: 1.5em;
}
.green-box {
background-color: green;
margin: 20px 40px 20px 40px;
}
</style>
<h5 class="injected-text">margin</h5>
<div class="box yellow-box">
<h5 class="box red-box">padding</h5>
<h5 class="box green-box">padding</h5>
</div>
```

View File

@ -0,0 +1,142 @@
---
id: bad87fee1348bd9aecf08806
title: CSS クラスで要素のスタイルを指定する
challengeType: 0
videoUrl: 'https://scrimba.com/c/c2MvDtV'
forumTopicId: 18337
dashedName: use-a-css-class-to-style-an-element
---
# --description--
クラスは再利用可能なスタイルで、HTML 要素に追加できます。
下記は CSS クラス宣言の例です:
```html
<style>
.blue-text {
color: blue;
}
</style>
```
`<style>` タグ内に、`blue-text` という CSS クラスを作成したことがわかります。 次のようにして、HTML 要素にクラスを適用できます: `<h2 class="blue-text">CatPhotoApp</h2>`. CSS の `style` 要素の中では、クラス名がピリオドで始まることに注意してください。 HTML 要素の class 属性では、クラス名にピリオドをつけません。
# --instructions--
`style` 要素の中の `h2` セレクターを `.red-text` に変更し、color の値を `blue` から `red` に変更してください。
`h2` 要素に `class` 属性を追加し、値を `red-text` にしてください。
# --hints--
`h2` 要素が赤で表示されている必要があります。
```js
assert($('h2').css('color') === 'rgb(255, 0, 0)');
```
`h2` 要素にはクラス `red-text` が必要です。
```js
assert($('h2').hasClass('red-text'));
```
スタイルシートに `red-text` クラスの宣言があり、color が `red` に設定されている必要があります。
```js
assert(code.match(/\.red-text\s*\{\s*color\s*:\s*red;?\s*\}/g));
```
`h2` 要素で `style="color: red"` のようなインラインスタイル宣言を使用しないでください。
```js
assert($('h2').attr('style') === undefined);
```
# --seed--
## --seed-contents--
```html
<style>
h2 {
color: blue;
}
</style>
<h2>CatPhotoApp</h2>
<main>
<p>Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
<div>
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
</div>
<form action="https://freecatphotoapp.com/submit-cat-photo">
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
<label><input type="checkbox" name="personality" checked> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Energetic</label><br>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
```
# --solutions--
```html
<style>
.red-text {
color: red;
}
</style>
<h2 class="red-text">CatPhotoApp</h2>
<main>
<p>Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
<div>
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
</div>
<form action="https://freecatphotoapp.com/submit-cat-photo">
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
<label><input type="checkbox" name="personality" checked> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Energetic</label><br>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
```

View File

@ -0,0 +1,287 @@
---
id: 5a9d727a424fe3d0e10cad12
title: カスタム CSS 変数を使用する
challengeType: 0
videoUrl: 'https://scrimba.com/c/cM989ck'
forumTopicId: 301090
dashedName: use-a-custom-css-variable
---
# --description--
変数を作成したら、変数につけた名前を参照することで、その値を他の CSS プロパティに割り当てることができます。
```css
background: var(--penguin-skin);
```
上のコードは、適用された要素の背景色をグレーに変更します。`--penguin-skin` 変数の値がグレーだからです。 変数名が完全に一致しなければ、スタイルは適用されないことに注意してください。
# --instructions--
`--penguin-skin` 変数を、`penguin-top`, `penguin-bottom`, `right-hand`, `left-hand` クラスの `background` プロパティに適用してください。
# --hints--
`--penguin-skin` 変数を `penguin-top` クラスの `background` プロパティに適用してください。
```js
assert(
code.match(
/.penguin-top\s*?{[\s\S]*background\s*?:\s*?var\s*?\(\s*?--penguin-skin\s*?\)\s*?;[\s\S]*}[\s\S]*.penguin-bottom\s{/gi
)
);
```
`--penguin-skin` 変数を `penguin-bottom` クラスの `background` プロパティに適用してください。
```js
assert(
code.match(
/.penguin-bottom\s*?{[\s\S]*background\s*?:\s*?var\s*?\(\s*?--penguin-skin\s*?\)\s*?;[\s\S]*}[\s\S]*.right-hand\s{/gi
)
);
```
`--penguin-skin` 変数を `right-hand` クラスの `background` プロパティに適用してください。
```js
assert(
code.match(
/.right-hand\s*?{[\s\S]*background\s*?:\s*?var\s*?\(\s*?--penguin-skin\s*?\)\s*?;[\s\S]*}[\s\S]*.left-hand\s{/gi
)
);
```
`--penguin-skin` 変数を `left-hand` クラスの `background` プロパティに適用してください。
```js
assert(
code.match(
/.left-hand\s*?{[\s\S]*background\s*?:\s*?var\s*?\(\s*?--penguin-skin\s*?\)\s*?;[\s\S]*}/gi
)
);
```
# --seed--
## --seed-contents--
```html
<style>
.penguin {
--penguin-skin: gray;
position: relative;
margin: auto;
display: block;
margin-top: 5%;
width: 300px;
height: 300px;
}
.penguin-top {
top: 10%;
left: 25%;
/* Change code below this line */
background: black;
/* Change code above this line */
width: 50%;
height: 45%;
border-radius: 70% 70% 60% 60%;
}
.penguin-bottom {
top: 40%;
left: 23.5%;
/* Change code below this line */
background: black;
/* Change code above this line */
width: 53%;
height: 45%;
border-radius: 70% 70% 100% 100%;
}
.right-hand {
top: 0%;
left: -5%;
/* Change code below this line */
background: black;
/* Change code above this line */
width: 30%;
height: 60%;
border-radius: 30% 30% 120% 30%;
transform: rotate(45deg);
z-index: -1;
}
.left-hand {
top: 0%;
left: 75%;
/* Change code below this line */
background: black;
/* Change code above this line */
width: 30%;
height: 60%;
border-radius: 30% 30% 30% 120%;
transform: rotate(-45deg);
z-index: -1;
}
.right-cheek {
top: 15%;
left: 35%;
background: white;
width: 60%;
height: 70%;
border-radius: 70% 70% 60% 60%;
}
.left-cheek {
top: 15%;
left: 5%;
background: white;
width: 60%;
height: 70%;
border-radius: 70% 70% 60% 60%;
}
.belly {
top: 60%;
left: 2.5%;
background: white;
width: 95%;
height: 100%;
border-radius: 120% 120% 100% 100%;
}
.right-feet {
top: 85%;
left: 60%;
background: orange;
width: 15%;
height: 30%;
border-radius: 50% 50% 50% 50%;
transform: rotate(-80deg);
z-index: -2222;
}
.left-feet {
top: 85%;
left: 25%;
background: orange;
width: 15%;
height: 30%;
border-radius: 50% 50% 50% 50%;
transform: rotate(80deg);
z-index: -2222;
}
.right-eye {
top: 45%;
left: 60%;
background: black;
width: 15%;
height: 17%;
border-radius: 50%;
}
.left-eye {
top: 45%;
left: 25%;
background: black;
width: 15%;
height: 17%;
border-radius: 50%;
}
.sparkle {
top: 25%;
left: 15%;
background: white;
width: 35%;
height: 35%;
border-radius: 50%;
}
.blush-right {
top: 65%;
left: 15%;
background: pink;
width: 15%;
height: 10%;
border-radius: 50%;
}
.blush-left {
top: 65%;
left: 70%;
background: pink;
width: 15%;
height: 10%;
border-radius: 50%;
}
.beak-top {
top: 60%;
left: 40%;
background: orange;
width: 20%;
height: 10%;
border-radius: 50%;
}
.beak-bottom {
top: 65%;
left: 42%;
background: orange;
width: 16%;
height: 10%;
border-radius: 50%;
}
body {
background:#c6faf1;
}
.penguin * {
position: absolute;
}
</style>
<div class="penguin">
<div class="penguin-bottom">
<div class="right-hand"></div>
<div class="left-hand"></div>
<div class="right-feet"></div>
<div class="left-feet"></div>
</div>
<div class="penguin-top">
<div class="right-cheek"></div>
<div class="left-cheek"></div>
<div class="belly"></div>
<div class="right-eye">
<div class="sparkle"></div>
</div>
<div class="left-eye">
<div class="sparkle"></div>
</div>
<div class="blush-right"></div>
<div class="blush-left"></div>
<div class="beak-top"></div>
<div class="beak-bottom"></div>
</div>
</div>
```
# --solutions--
```html
<style>.penguin-top {background: var(--penguin-skin);} .penguin-bottom {background: var(--penguin-skin);} .right-hand {background: var(--penguin-skin);} .left-hand {background: var(--penguin-skin);}</style>
```

View File

@ -0,0 +1,281 @@
---
id: 5a9d72ad424fe3d0e10cad16
title: メディアクエリを使用して変数を変更する
challengeType: 0
videoUrl: 'https://scrimba.com/c/cWmL8UP'
forumTopicId: 301091
dashedName: use-a-media-query-to-change-a-variable
---
# --description--
CSS 変数は、メディアクエリの使い方をシンプルにできます。
たとえば、画面がメディアクエリのブレークポイントより小さい、または大きい場合に、変数の値を変更することができます。そしてその変数が使用されている場所すべてにそのスタイルを適用できます。
# --instructions--
`media query``:root` セレクターの中で、`--penguin-size` を再定義して値が `200px` となるように変更してください。 また、`--penguin-skin` も再定義し、`black` の値を設定してください。 その後、プレビューの表示サイズを変更して、この変更が動作していることを確認してください。
# --hints--
`:root``--penguin-size` 変数に `200px` を再代入する必要があります。
```js
assert(
code.match(
/media\s*?\(\s*?max-width\s*?:\s*?350px\s*?\)\s*?{[\s\S]*:root\s*?{[\s\S]*--penguin-size\s*?:\s*?200px\s*?;[\s\S]*}[\s\S]*}/gi
)
);
```
`:root``--penguin-skin` 変数に `black` を再代入する必要があります。
```js
assert(
code.match(
/media\s*?\(\s*?max-width\s*?:\s*?350px\s*?\)\s*?{[\s\S]*:root\s*?{[\s\S]*--penguin-skin\s*?:\s*?black\s*?;[\s\S]*}[\s\S]*}/gi
)
);
```
# --seed--
## --seed-contents--
```html
<style>
:root {
--penguin-size: 300px;
--penguin-skin: gray;
--penguin-belly: white;
--penguin-beak: orange;
}
@media (max-width: 350px) {
:root {
/* Only change code below this line */
/* Only change code above this line */
}
}
.penguin {
position: relative;
margin: auto;
display: block;
margin-top: 5%;
width: var(--penguin-size, 300px);
height: var(--penguin-size, 300px);
}
.right-cheek {
top: 15%;
left: 35%;
background: var(--penguin-belly, white);
width: 60%;
height: 70%;
border-radius: 70% 70% 60% 60%;
}
.left-cheek {
top: 15%;
left: 5%;
background: var(--penguin-belly, white);
width: 60%;
height: 70%;
border-radius: 70% 70% 60% 60%;
}
.belly {
top: 60%;
left: 2.5%;
background: var(--penguin-belly, white);
width: 95%;
height: 100%;
border-radius: 120% 120% 100% 100%;
}
.penguin-top {
top: 10%;
left: 25%;
background: var(--penguin-skin, gray);
width: 50%;
height: 45%;
border-radius: 70% 70% 60% 60%;
}
.penguin-bottom {
top: 40%;
left: 23.5%;
background: var(--penguin-skin, gray);
width: 53%;
height: 45%;
border-radius: 70% 70% 100% 100%;
}
.right-hand {
top: 5%;
left: 25%;
background: var(--penguin-skin, black);
width: 30%;
height: 60%;
border-radius: 30% 30% 120% 30%;
transform: rotate(130deg);
z-index: -1;
animation-duration: 3s;
animation-name: wave;
animation-iteration-count: infinite;
transform-origin:0% 0%;
animation-timing-function: linear;
}
@keyframes wave {
10% {
transform: rotate(110deg);
}
20% {
transform: rotate(130deg);
}
30% {
transform: rotate(110deg);
}
40% {
transform: rotate(130deg);
}
}
.left-hand {
top: 0%;
left: 75%;
background: var(--penguin-skin, gray);
width: 30%;
height: 60%;
border-radius: 30% 30% 30% 120%;
transform: rotate(-45deg);
z-index: -1;
}
.right-feet {
top: 85%;
left: 60%;
background: var(--penguin-beak, orange);
width: 15%;
height: 30%;
border-radius: 50% 50% 50% 50%;
transform: rotate(-80deg);
z-index: -2222;
}
.left-feet {
top: 85%;
left: 25%;
background: var(--penguin-beak, orange);
width: 15%;
height: 30%;
border-radius: 50% 50% 50% 50%;
transform: rotate(80deg);
z-index: -2222;
}
.right-eye {
top: 45%;
left: 60%;
background: black;
width: 15%;
height: 17%;
border-radius: 50%;
}
.left-eye {
top: 45%;
left: 25%;
background: black;
width: 15%;
height: 17%;
border-radius: 50%;
}
.sparkle {
top: 25%;
left:-23%;
background: white;
width: 150%;
height: 100%;
border-radius: 50%;
}
.blush-right {
top: 65%;
left: 15%;
background: pink;
width: 15%;
height: 10%;
border-radius: 50%;
}
.blush-left {
top: 65%;
left: 70%;
background: pink;
width: 15%;
height: 10%;
border-radius: 50%;
}
.beak-top {
top: 60%;
left: 40%;
background: var(--penguin-beak, orange);
width: 20%;
height: 10%;
border-radius: 50%;
}
.beak-bottom {
top: 65%;
left: 42%;
background: var(--penguin-beak, orange);
width: 16%;
height: 10%;
border-radius: 50%;
}
body {
background:#c6faf1;
}
.penguin * {
position: absolute;
}
</style>
<div class="penguin">
<div class="penguin-bottom">
<div class="right-hand"></div>
<div class="left-hand"></div>
<div class="right-feet"></div>
<div class="left-feet"></div>
</div>
<div class="penguin-top">
<div class="right-cheek"></div>
<div class="left-cheek"></div>
<div class="belly"></div>
<div class="right-eye">
<div class="sparkle"></div>
</div>
<div class="left-eye">
<div class="sparkle"></div>
</div>
<div class="blush-right"></div>
<div class="blush-left"></div>
<div class="beak-top"></div>
<div class="beak-bottom"></div>
</div>
</div>
```
# --solutions--
```html
<style>@media (max-width: 350px) {:root {--penguin-size: 200px; --penguin-skin: black;}}</style>
```

View File

@ -0,0 +1,128 @@
---
id: bad87fee1348bd9aedf08719
title: 16 進数コードの短縮形を使用する
challengeType: 0
videoUrl: 'https://scrimba.com/c/cRkpKAm'
forumTopicId: 18338
dashedName: use-abbreviated-hex-code
---
# --description--
1600 万色以上と言われて圧倒される人も多いでしょう。 また、16 進数のコードを覚えるのは大変です。 幸い、それを短縮できます。
例えば、赤色の 16 進数コード `#FF0000``#F00` と短縮できます。 この短縮形は、1 桁ずつ赤、緑、青を表します。
これは、表現可能な色の数を約 4,000 色に減少させます。 しかし、ブラウザは `#FF0000``#F00` をまったく同じ色として解釈します。
# --instructions--
短縮形の 16 進数コードを使用して、正しい要素に色を付けてみましょう。
<table class='table table-striped'><tbody><tr><th></th><th>短縮 16 進数コード</th></tr><tr><td>シアン</td><td><code>#0FF</code></td></tr><tr><td></td><td><code>#0F0</code></td></tr><tr><td></td><td><code>#F00</code></td></tr><tr><td>フューシャ</td><td><code>#F0F</code></td></tr></tbody></table>
# --hints--
テキストが `I am red!``h1` 要素の `color` は赤にしてください。
```js
assert($('.red-text').css('color') === 'rgb(255, 0, 0)');
```
赤を指定するために、16 進数コード `#FF0000` の代わりに短縮形の `hex code` を使用してください。
```js
assert(code.match(/\.red-text\s*?{\s*?color\s*:\s*?#F00\s*?;?\s*?}/gi));
```
テキストが `I am green!``h1` 要素の `color` は緑にしてください。
```js
assert($('.green-text').css('color') === 'rgb(0, 255, 0)');
```
緑を指定するために、16 進数コード `#00FF00` の代わりに短縮形の `hex code` を使用してください。
```js
assert(code.match(/\.green-text\s*?{\s*?color\s*:\s*?#0F0\s*?;?\s*?}/gi));
```
テキストが `I am cyan!``h1` 要素の `color` はシアンにしてください。
```js
assert($('.cyan-text').css('color') === 'rgb(0, 255, 255)');
```
シアンを指定するために、16 進数コード `#00FFFF` の代わりに短縮形の `hex code` を使用してください。
```js
assert(code.match(/\.cyan-text\s*?{\s*?color\s*:\s*?#0FF\s*?;?\s*?}/gi));
```
テキストが `I am fuchsia!``h1` 要素の `color` はフューシャにしてください。
```js
assert($('.fuchsia-text').css('color') === 'rgb(255, 0, 255)');
```
フューシャを指定するために、16 進数コード `#FF00FF` の代わりに短縮形の `hex code` を使用してください。
```js
assert(code.match(/\.fuchsia-text\s*?{\s*?color\s*:\s*?#F0F\s*?;?\s*?}/gi));
```
# --seed--
## --seed-contents--
```html
<style>
.red-text {
color: #000000;
}
.fuchsia-text {
color: #000000;
}
.cyan-text {
color: #000000;
}
.green-text {
color: #000000;
}
</style>
<h1 class="red-text">I am red!</h1>
<h1 class="fuchsia-text">I am fuchsia!</h1>
<h1 class="cyan-text">I am cyan!</h1>
<h1 class="green-text">I am green!</h1>
```
# --solutions--
```html
<style>
.red-text {
color: #F00;
}
.fuchsia-text {
color: #F0F;
}
.cyan-text {
color: #0FF;
}
.green-text {
color: #0F0;
}
</style>
<h1 class="red-text">I am red!</h1>
<h1 class="fuchsia-text">I am fuchsia!</h1>
<h1 class="cyan-text">I am cyan!</h1>
<h1 class="green-text">I am green!</h1>
```

View File

@ -0,0 +1,197 @@
---
id: bad87dee1348bd9aede07836
title: 要素のスタイル指定に id 属性を使用する
challengeType: 0
videoUrl: 'https://scrimba.com/c/cakyZfL'
forumTopicId: 18339
dashedName: use-an-id-attribute-to-style-an-element
---
# --description--
`id` 属性についての 1 つの良い点は、クラスと同じように、CSS を使用してスタイルを指定できることです。
ただし、`id` は再利用できず、1 つの要素にのみ適用されるべきです。 また `id` はクラスより高い特定性 (重要度) を持っているので、もし両方が同じ要素に適用されていてスタイル指定を競合 (コンフリクト) させている場合には、`id` のスタイルが適用されます。
ここでは、`cat-photo-element` という `id` 属性で要素を選択し、緑の背景色を与える方法の例を示します。 `style` 要素の中に以下を追加します:
```css
#cat-photo-element {
background-color: green;
}
```
`style` 要素内では、クラス名の前に `.` を付けることでクラスを参照することに注意してください。 idを参照するには、`#` を名前の前に置きます。
# --instructions--
`id` 属性が `cat-photo-form` のフォームに、緑の背景色を設定してみましょう。
# --hints--
`form` 要素は、`cat-photo-form` という id を持つ必要があります。
```js
assert($('form').attr('id') === 'cat-photo-form');
```
`form` 要素は `background-color` を緑に設定されている必要があります。
```js
assert($('#cat-photo-form').css('background-color') === 'rgb(0, 128, 0)');
```
`form` 要素には `id` 属性が必要です。
```js
assert(
code.match(/<form.*cat-photo-form.*>/gi) &&
code.match(/<form.*cat-photo-form.*>/gi).length > 0
);
```
`form` には `class` および `style` 属性を指定しないでください。
```js
assert(!code.match(/<form.*style.*>/gi) && !code.match(/<form.*class.*>/gi));
```
# --seed--
## --seed-contents--
```html
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
.red-text {
color: red;
}
h2 {
font-family: Lobster, monospace;
}
p {
font-size: 16px;
font-family: monospace;
}
.thick-green-border {
border-color: green;
border-width: 10px;
border-style: solid;
border-radius: 50%;
}
.smaller-image {
width: 100px;
}
.silver-background {
background-color: silver;
}
</style>
<h2 class="red-text">CatPhotoApp</h2>
<main>
<p class="red-text">Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img class="smaller-image thick-green-border" src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
<div class="silver-background">
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
</div>
<form action="https://freecatphotoapp.com/submit-cat-photo" id="cat-photo-form">
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
<label><input type="checkbox" name="personality" checked> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Energetic</label><br>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
```
# --solutions--
```html
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
.red-text {
color: red;
}
h2 {
font-family: Lobster, monospace;
}
p {
font-size: 16px;
font-family: monospace;
}
.thick-green-border {
border-color: green;
border-width: 10px;
border-style: solid;
border-radius: 50%;
}
.smaller-image {
width: 100px;
}
.silver-background {
background-color: silver;
}
#cat-photo-form {
background-color: green;
}
</style>
<h2 class="red-text">CatPhotoApp</h2>
<main>
<p class="red-text">Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img class="smaller-image thick-green-border" src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
<div class="silver-background">
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
</div>
<form action="https://freecatphotoapp.com/submit-cat-photo" id="cat-photo-form">
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
<label><input type="checkbox" name="personality" checked> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Energetic</label><br>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
```

View File

@ -0,0 +1,210 @@
---
id: 58c383d33e2e3259241f3076
title: 属性セレクターで要素のスタイルを指定する
challengeType: 0
videoUrl: 'https://scrimba.com/c/cnpymfJ'
forumTopicId: 301092
dashedName: use-attribute-selectors-to-style-elements
---
# --description--
ここまで、スタイルを指定したい要素に `id``class` 属性を追加してきました。 これらは ID およびクラスセレクターと呼ばれています。 スタイルを適用する要素のグループを選択するために使える CSS セレクターは他にもあります。
CSS セレクターの使い方を練習するために、猫の写真アプリをもう一度取り上げます。
このチャレンジでは、`[attr=value]` という属性セレクターを使用して、猫の写真アプリのチェックボックスのスタイルを変更します。 このセレクターは、特定の属性値を持つ要素とマッチし、スタイルを適用します。 例えば、以下のコードは `type` 属性に `radio` の値を持つすべての要素のマージンを変更します:
```css
[type='radio'] {
margin: 20px 0px 20px 0px;
}
```
# --instructions--
`type` 属性セレクターを使用して、猫の写真アプリのチェックボックスの上側のマージンを 10px、下側のマージンを 15px に設定してみましょう。
# --hints--
チェックボックスの選択には `type` 属性セレクターを使用してください。
```js
assert(
code.match(
/<style>[\s\S]*?\[\s*?type\s*?=\s*?("|')checkbox\1\s*?\]\s*?{[\s\S]*?}[\s\S]*?<\/style>/gi
)
);
```
チェックボックスの上部のマージンは 10px である必要があります。
```js
assert(
(function () {
var count = 0;
$("[type='checkbox']").each(function () {
if ($(this).css('marginTop') === '10px') {
count++;
}
});
return count === 3;
})()
);
```
チェックボックスの下部のマージンは 15px である必要があります。
```js
assert(
(function () {
var count = 0;
$("[type='checkbox']").each(function () {
if ($(this).css('marginBottom') === '15px') {
count++;
}
});
return count === 3;
})()
);
```
# --seed--
## --seed-contents--
```html
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
.red-text {
color: red;
}
h2 {
font-family: Lobster, monospace;
}
p {
font-size: 16px;
font-family: monospace;
}
.thick-green-border {
border-color: green;
border-width: 10px;
border-style: solid;
border-radius: 50%;
}
.smaller-image {
width: 100px;
}
.silver-background {
background-color: silver;
}
</style>
<h2 class="red-text">CatPhotoApp</h2>
<main>
<p class="red-text">Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img class="smaller-image thick-green-border" src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
<div class="silver-background">
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
</div>
<form action="https://freecatphotoapp.com/submit-cat-photo" id="cat-photo-form">
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
<label><input type="checkbox" name="personality" checked> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Energetic</label><br>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
```
# --solutions--
```html
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
.red-text {
color: red;
}
h2 {
font-family: Lobster, monospace;
}
p {
font-size: 16px;
font-family: monospace;
}
.thick-green-border {
border-color: green;
border-width: 10px;
border-style: solid;
border-radius: 50%;
}
.smaller-image {
width: 100px;
}
.silver-background {
background-color: silver;
}
[type='checkbox'] {
margin-top: 10px;
margin-bottom: 15px;
}
</style>
<h2 class="red-text">CatPhotoApp</h2>
<main>
<p class="red-text">Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img class="smaller-image thick-green-border" src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
<div class="silver-background">
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
</div>
<form action="https://freecatphotoapp.com/submit-cat-photo" id="cat-photo-form">
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
<label><input type="checkbox" name="personality" checked> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Energetic</label><br>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
```

View File

@ -0,0 +1,143 @@
---
id: bad87fee1348bd9afdf08726
title: 時計回りの表記を使用して要素のマージンを指定する
challengeType: 0
videoUrl: 'https://scrimba.com/c/cnpybAd'
forumTopicId: 18345
dashedName: use-clockwise-notation-to-specify-the-margin-of-an-element
---
# --description--
今度は `margin` で同じことをやってみましょう。
要素の `margin-top`, `margin-right`, `margin-bottom`, `margin-left` のプロパティを個々に指定する代わりに、次のようにしてすべてを 1 行で指定することができます:
```css
margin: 10px 20px 10px 20px;
```
これら 4 つの値は時計のように上、右、下、左の順に働き、そして辺ごとの margin 指定を使用するのとまったく同じ結果になります。
# --instructions--
時計回りの表記を使用して、`blue-box` クラスの要素に上側と左側は `40px`、下側と右側は `20px` の margin を設定してください。
# --hints--
`blue-box` クラスは、要素の上側に `40px``margin` を与える必要があります。
```js
assert($('.blue-box').css('margin-top') === '40px');
```
`blue-box` クラスは、要素の右側に `20px``margin` を与える必要があります。
```js
assert($('.blue-box').css('margin-right') === '20px');
```
`blue-box` クラスは、要素の下側に `20px``margin` を与える必要があります。
```js
assert($('.blue-box').css('margin-bottom') === '20px');
```
`blue-box` クラスは、要素の左側に `40px``margin` を与える必要があります。
```js
assert($('.blue-box').css('margin-left') === '40px');
```
`blue-box` クラスのマージンの設定に時計回りの表記を使用してください。
```js
assert(
/\.blue-box\s*{[\s\S]*margin[\s]*:\s*\d+px\s+\d+px\s+\d+px\s+\d+px(;\s*[^}]+\s*}|;?\s*})/.test(
__helpers.removeCssComments($('style').text())
)
);
```
# --seed--
## --seed-contents--
```html
<style>
.injected-text {
margin-bottom: -25px;
text-align: center;
}
.box {
border-style: solid;
border-color: black;
border-width: 5px;
text-align: center;
}
.yellow-box {
background-color: yellow;
padding: 20px 40px 20px 40px;
}
.red-box {
background-color: crimson;
color: #fff;
margin: 20px 40px 20px 40px;
}
.blue-box {
background-color: blue;
color: #fff;
}
</style>
<h5 class="injected-text">margin</h5>
<div class="box yellow-box">
<h5 class="box red-box">padding</h5>
<h5 class="box blue-box">padding</h5>
</div>
```
# --solutions--
```html
<style>
.injected-text {
margin-bottom: -25px;
text-align: center;
}
.box {
border-style: solid;
border-color: black;
border-width: 5px;
text-align: center;
}
.yellow-box {
background-color: yellow;
padding: 20px 40px 20px 40px;
}
.red-box {
background-color: crimson;
color: #fff;
margin: 20px 40px 20px 40px;
}
.blue-box {
background-color: blue;
color: #fff;
margin: 40px 20px 20px 40px;
}
</style>
<h5 class="injected-text">margin</h5>
<div class="box yellow-box">
<h5 class="box red-box">padding</h5>
<h5 class="box blue-box">padding</h5>
</div>
```

View File

@ -0,0 +1,141 @@
---
id: bad87fee1348bd9aedf08826
title: 時計回りの表記を使用して要素のパディングを指定する
challengeType: 0
videoUrl: 'https://scrimba.com/c/cB7mBS9'
forumTopicId: 18346
dashedName: use-clockwise-notation-to-specify-the-padding-of-an-element
---
# --description--
要素の `padding-top`, `padding-right`, `padding-bottom`, `padding-left` のプロパティを個々に指定する代わりに、次のようにしてすべてを 1 行で指定することができます:
```css
padding: 10px 20px 10px 20px;
```
これら 4 つの値は時計のように上、右、下、左の順に働き、そして辺ごとの padding 指定を使用するのとまったく同じ結果になります。
# --instructions--
時計回りの表記を使用して、`.blue-box` クラスの `padding` を上側と左側は `40px`、下側と右側は `20px` に設定してください。
# --hints--
`blue-box` クラスは、要素の上側に `40px``padding` を与える必要があります。
```js
assert($('.blue-box').css('padding-top') === '40px');
```
`blue-box` クラスは、要素の右側に `20px``padding` を与える必要があります。
```js
assert($('.blue-box').css('padding-right') === '20px');
```
`blue-box` クラスは、要素の下側に `20px``padding` を与える必要があります。
```js
assert($('.blue-box').css('padding-bottom') === '20px');
```
`blue-box` クラスは、要素の左側に `40px``padding` を与える必要があります。
```js
assert($('.blue-box').css('padding-left') === '40px');
```
`blue-box` クラスのパディングの設定には時計回りの表記を使用してください。
```js
assert(
/\.blue-box\s*{[\s\S]*padding[\s]*:\s*\d+px\s+\d+px\s+\d+px\s+\d+px(;\s*[^}]+\s*}|;?\s*})/.test(
__helpers.removeCssComments($('style').text())
)
);
```
# --seed--
## --seed-contents--
```html
<style>
.injected-text {
margin-bottom: -25px;
text-align: center;
}
.box {
border-style: solid;
border-color: black;
border-width: 5px;
text-align: center;
}
.yellow-box {
background-color: yellow;
padding: 20px 40px 20px 40px;
}
.red-box {
background-color: crimson;
color: #fff;
padding: 20px 40px 20px 40px;
}
.blue-box {
background-color: blue;
color: #fff;
}
</style>
<h5 class="injected-text">margin</h5>
<div class="box yellow-box">
<h5 class="box red-box">padding</h5>
<h5 class="box blue-box">padding</h5>
</div>
```
# --solutions--
```html
<style>
.injected-text {
margin-bottom: -25px;
text-align: center;
}
.box {
border-style: solid;
border-color: black;
border-width: 5px;
text-align: center;
}
.yellow-box {
background-color: yellow;
padding: 20px 40px 20px 40px;
}
.red-box {
background-color: crimson;
color: #fff;
padding: 20px 40px 20px 40px;
}
.blue-box {
background-color: blue;
color: #fff;
padding: 40px 20px 20px 40px;
}
</style>
<h5 class="injected-text">margin</h5>
<div class="box yellow-box">
<h5 class="box red-box">padding</h5>
<h5 class="box blue-box">padding</h5>
</div>
```

View File

@ -0,0 +1,158 @@
---
id: bad87fee1348bd9aedf08805
title: CSS セレクターで要素のスタイルを指定する
challengeType: 0
videoUrl: 'https://scrimba.com/c/cJKMBT2'
forumTopicId: 18349
dashedName: use-css-selectors-to-style-elements
---
# --description--
CSS では、ページ上の要素の見た目を変更するために使える CSS プロパティが多数あります。
`<h2 style="color: red;">CatPhotoApp</h2>` と入力することで、その 1 つの `h2` 要素にインライン CSS でスタイルを設定することができました。CSS はカスケーディングスタイルシート (Cascading Style Sheets) の略です。
これは要素のスタイルを指定する 1 つの方法ですが、CSS を適用するにはより良い方法があります。
コードの一番上に、次のように `style` ブロックを作成します:
```html
<style>
</style>
```
その style ブロックの中で、すべての `h2` 要素を指す <dfn>CSS セレクター</dfn> を作成できます。 例えば、すべての `h2` 要素を赤にしたい場合は、次のようなスタイルルールを追加します:
```html
<style>
h2 {
color: red;
}
</style>
```
各要素のスタイルルールを囲むように、波括弧 (`{``}`) を始めと終わりどちらにも置くことが重要です。 また、要素のスタイル定義は必ず style タグの開始タグと終了タグの間にある必要があります。 最後に、要素の各スタイルルールの最後にセミコロンを必ず追加してください。
# --instructions--
`h2` 要素の style 属性を削除し、代わりに CSS の `style` ブロックを作成してください。 すべての `h2` 要素を青にするために必要な CSS を追加してください。
# --hints--
`h2` 要素から `style` 属性を削除してください。
```js
assert(!$('h2').attr('style'));
```
`style` 要素を作成してください。
```js
assert($('style') && $('style').length >= 1);
```
`h2` 要素が青で表示されている必要があります。
```js
assert($('h2').css('color') === 'rgb(0, 0, 255)');
```
スタイルシートの `h2` の宣言は、セミコロンと閉じ括弧を持つ有効な状態でなければなりません。
```js
assert(code.match(/h2\s*\{\s*color\s*:.*;\s*\}/g));
```
すべての `style` 要素は有効でなければならず、また終了タグが必要です。
```js
assert(
code.match(/<\/style>/g) &&
code.match(/<\/style>/g).length ===
(
code.match(
/<style((\s)*((type|media|scoped|title|disabled)="[^"]*")?(\s)*)*>/g
) || []
).length
);
```
# --seed--
## --seed-contents--
```html
<h2 style="color: red;">CatPhotoApp</h2>
<main>
<p>Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
<div>
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
</div>
<form action="https://freecatphotoapp.com/submit-cat-photo">
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
<label><input type="checkbox" name="personality" checked> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Energetic</label><br>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
```
# --solutions--
```html
<style>
h2 {
color: blue;
}
</style>
<h2>CatPhotoApp</h2>
<main>
<p>Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>
<div>
<p>Things cats love:</p>
<ul>
<li>cat nip</li>
<li>laser pointers</li>
<li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
<li>flea treatment</li>
<li>thunder</li>
<li>other cats</li>
</ol>
</div>
<form action="https://freecatphotoapp.com/submit-cat-photo">
<label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
<label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
<label><input type="checkbox" name="personality" checked> Loving</label>
<label><input type="checkbox" name="personality"> Lazy</label>
<label><input type="checkbox" name="personality"> Energetic</label><br>
<input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button>
</form>
</main>
```

View File

@ -0,0 +1,257 @@
---
id: 5a9d725e424fe3d0e10cad10
title: CSS 変数を使用して複数の要素をまとめて変更する
challengeType: 0
videoUrl: 'https://scrimba.com/c/c6bDECm'
forumTopicId: 301093
dashedName: use-css-variables-to-change-several-elements-at-once
---
# --description--
<dfn>CSS変数</dfn> は、1 つの値だけを変更することで多くの CSS スタイルプロパティを一度に変更できるようにする強力な方法です。
以下の手順に従って、3 つの値を変更するだけで多くの要素のスタイルを変更できることを確認してみましょう。
# --instructions--
`penguin` クラスの中で、`black` の値を `gray` に、`gray` の値を `white` に、`yellow` の値を `orange` に変更してください。
# --hints--
`penguin` クラスは `--penguin-skin` 変数を宣言し、`gray` を代入している必要があります。
```js
assert(
code.match(/.penguin\s*?{[\s\S]*--penguin-skin\s*?:\s*?gray\s*?;[\s\S]*}/gi)
);
```
`penguin` クラスは `--penguin-belly` 変数を宣言し、`white` を代入している必要があります。
```js
assert(
code.match(/.penguin\s*?{[\s\S]*--penguin-belly\s*?:\s*?white\s*?;[\s\S]*}/gi)
);
```
`penguin` クラスは `--penguin-beak` 変数を宣言し、`orange` を代入している必要があります。
```js
assert(
code.match(/.penguin\s*?{[\s\S]*--penguin-beak\s*?:\s*?orange\s*?;[\s\S]*}/gi)
);
```
# --seed--
## --seed-contents--
```html
<style>
.penguin {
/* Only change code below this line */
--penguin-skin: black;
--penguin-belly: gray;
--penguin-beak: yellow;
/* Only change code above this line */
position: relative;
margin: auto;
display: block;
margin-top: 5%;
width: 300px;
height: 300px;
}
.penguin-top {
top: 10%;
left: 25%;
background: var(--penguin-skin, gray);
width: 50%;
height: 45%;
border-radius: 70% 70% 60% 60%;
}
.penguin-bottom {
top: 40%;
left: 23.5%;
background: var(--penguin-skin, gray);
width: 53%;
height: 45%;
border-radius: 70% 70% 100% 100%;
}
.right-hand {
top: 0%;
left: -5%;
background: var(--penguin-skin, gray);
width: 30%;
height: 60%;
border-radius: 30% 30% 120% 30%;
transform: rotate(45deg);
z-index: -1;
}
.left-hand {
top: 0%;
left: 75%;
background: var(--penguin-skin, gray);
width: 30%;
height: 60%;
border-radius: 30% 30% 30% 120%;
transform: rotate(-45deg);
z-index: -1;
}
.right-cheek {
top: 15%;
left: 35%;
background: var(--penguin-belly, white);
width: 60%;
height: 70%;
border-radius: 70% 70% 60% 60%;
}
.left-cheek {
top: 15%;
left: 5%;
background: var(--penguin-belly, white);
width: 60%;
height: 70%;
border-radius: 70% 70% 60% 60%;
}
.belly {
top: 60%;
left: 2.5%;
background: var(--penguin-belly, white);
width: 95%;
height: 100%;
border-radius: 120% 120% 100% 100%;
}
.right-feet {
top: 85%;
left: 60%;
background: var(--penguin-beak, orange);
width: 15%;
height: 30%;
border-radius: 50% 50% 50% 50%;
transform: rotate(-80deg);
z-index: -2222;
}
.left-feet {
top: 85%;
left: 25%;
background: var(--penguin-beak, orange);
width: 15%;
height: 30%;
border-radius: 50% 50% 50% 50%;
transform: rotate(80deg);
z-index: -2222;
}
.right-eye {
top: 45%;
left: 60%;
background: black;
width: 15%;
height: 17%;
border-radius: 50%;
}
.left-eye {
top: 45%;
left: 25%;
background: black;
width: 15%;
height: 17%;
border-radius: 50%;
}
.sparkle {
top: 25%;
left: 15%;
background: white;
width: 35%;
height: 35%;
border-radius: 50%;
}
.blush-right {
top: 65%;
left: 15%;
background: pink;
width: 15%;
height: 10%;
border-radius: 50%;
}
.blush-left {
top: 65%;
left: 70%;
background: pink;
width: 15%;
height: 10%;
border-radius: 50%;
}
.beak-top {
top: 60%;
left: 40%;
background: var(--penguin-beak, orange);
width: 20%;
height: 10%;
border-radius: 50%;
}
.beak-bottom {
top: 65%;
left: 42%;
background: var(--penguin-beak, orange);
width: 16%;
height: 10%;
border-radius: 50%;
}
body {
background:#c6faf1;
}
.penguin * {
position: absolute;
}
</style>
<div class="penguin">
<div class="penguin-bottom">
<div class="right-hand"></div>
<div class="left-hand"></div>
<div class="right-feet"></div>
<div class="left-feet"></div>
</div>
<div class="penguin-top">
<div class="right-cheek"></div>
<div class="left-cheek"></div>
<div class="belly"></div>
<div class="right-eye">
<div class="sparkle"></div>
</div>
<div class="left-eye">
<div class="sparkle"></div>
</div>
<div class="blush-right"></div>
<div class="blush-left"></div>
<div class="beak-top"></div>
<div class="beak-bottom"></div>
</div>
</div>
```
# --solutions--
```html
<style>.penguin {--penguin-skin: gray; --penguin-belly: white; --penguin-beak: orange;}</style>
```

View File

@ -0,0 +1,66 @@
---
id: bad87fee1348bd9aedf08726
title: 特定の色に 16 進数コードを使用する
challengeType: 0
videoUrl: 'https://scrimba.com/c/c8W9mHM'
forumTopicId: 18350
dashedName: use-hex-code-for-specific-colors
---
# --description--
CSS で色を表現する方法は他にもあることをご存知でしたか? これらの方法の一つは 16 進数 (hexadecimal) カラーコード、または hexadecimal を略して hex コードと呼ばれます。
私達は日常的に <dfn>10 進数</dfn>、つまり基数が 10 の数字を使用しています。10 進数では各桁に 0 から 9 の記号を使用します。 <dfn>16 進数</dfn> (または <dfn>16 進、ヘクサ、hex</dfn> など) は基数が 16 の数字です。 これは 16 個の異なる記号を使用することを意味します。 10 進数と同様に、0-9 の記号は 0 から 9 までの値を表します。 その後、A、B、C、D、E、F は 10 から 15 の値を表します。 これを合わせて 0 F で 16 進数の 1 桁を表し、合計 16 個の値をとることができます。 [16 進数について詳しくはこちら](https://www.freecodecamp.org/news/hexadecimal-number-system/) を参照してください。
CSS では、6 桁の 16 進数の数字を使用して色を表すことができます。2 桁ごとに赤 (R)、緑 (G)、青 (B) の成分を表します。 例えば、`#000000` は黒を表し、また表すことができる最も低い値です。 [RGB カラーモデルについて詳しくはこちら](https://www.freecodecamp.org/news/rgb-color-html-and-css-guide/#whatisthergbcolormodel) を参照してください。
```css
body {
color: #000000;
}
```
# --instructions--
`body` 要素の background-color の `black` を、16 進数コード表記 `#000000` に置き換えてください。
# --hints--
`body` 要素は background-color を黒に設定されている必要があります。
```js
assert($('body').css('background-color') === 'rgb(0, 0, 0)');
```
`black` という単語の代わりに、黒を表す `hex code` (16 進数コード) を使用します。
```js
assert(
code.match(
/body\s*{(([\s\S]*;\s*?)|\s*?)background.*\s*:\s*?#000(000)?((\s*})|(;[\s\S]*?}))/gi
)
);
```
# --seed--
## --seed-contents--
```html
<style>
body {
background-color: black;
}
</style>
```
# --solutions--
```html
<style>
body {
background-color: #000000;
}
</style>
```

View File

@ -0,0 +1,132 @@
---
id: bad87fee1348bd9aedf08721
title: 16 進数コードを使用して色を調整する
challengeType: 0
videoUrl: 'https://scrimba.com/c/cK89PhP'
forumTopicId: 18359
dashedName: use-hex-code-to-mix-colors
---
# --description--
復習になりますが、16 進数カラーコードは 6 桁の 16 進数の数字を使用し、2 桁ごとに赤 (R)、緑 (G)、青 (B) の成分を表して色を表現します。
この 3 つの純粋色 (赤、緑、青) から、それぞれの量を変更して 1,600 万色以上の色を作成することができます!
例えば、オレンジは純粋な赤にいくらかの緑を混ぜて作ることができ、青は使いません。 16 進数コードでこれを表すと、`#FFA500` となります。
`0` は 16 進数で最も低い数値であり、色が全く無いことを表します。
`F` は 16 進数では最も高い数値であり、可能な限り最大の明るさを表します。
# --instructions--
`style` 要素の中のカラーキーワードを正しい 16 進数カラーコードで置き換えてください。
<table class='table table-striped'><tbody><tr><th></th><th>16 進数カラーコード</th></tr><tr><td>ドジャーブルー</td><td><code>#1E90FF</code></td></tr><tr><td></td><td><code>#00FF00</code></td></tr><tr><td>オレンジ</td><td><code>#FFA500</code></td></tr><tr><td></td><td><code>#FF0000</code></td></tr></tbody></table>
# --hints--
テキストが `I am red!``h1` 要素の `color` は赤にしてください。
```js
assert($('.red-text').css('color') === 'rgb(255, 0, 0)');
```
`red` という単語の代わりに、赤を表す `hex code` (16 進数コード) を使用してください。
```js
assert(code.match(/\.red-text\s*?{\s*?color\s*:\s*?(#FF0000|#F00)\s*?;?\s*?}/gi));
```
テキストが `I am green!``h1` 要素の `color` は緑にしてください。
```js
assert($('.green-text').css('color') === 'rgb(0, 255, 0)');
```
`green` という単語の代わりに、緑を表す `hex code` (16 進数コード) を使用してください。
```js
assert(code.match(/\.green-text\s*?{\s*?color\s*:\s*?(#00FF00|#0F0)\s*?;?\s*?}/gi));
```
テキストが `I am dodger blue!``h1` 要素の `color` はドジャーブルーにしてください。
```js
assert($('.dodger-blue-text').css('color') === 'rgb(30, 144, 255)');
```
`dodgerblue` という単語の代わりに、ドジャーブルーを表す `hex code` (16 進数コード) を使用してください。
```js
assert(code.match(/\.dodger-blue-text\s*?{\s*?color\s*:\s*?#1E90FF\s*?;?\s*?}/gi));
```
テキストが `I am orange!``h1` 要素の `color` はオレンジにしてください。
```js
assert($('.orange-text').css('color') === 'rgb(255, 165, 0)');
```
`orange` という単語の代わりに、オレンジを表す `hex code` (16 進数コード) を使用してください。
```js
assert(code.match(/\.orange-text\s*?{\s*?color\s*:\s*?#FFA500\s*?;?\s*?}/gi));
```
# --seed--
## --seed-contents--
```html
<style>
.red-text {
color: black;
}
.green-text {
color: black;
}
.dodger-blue-text {
color: black;
}
.orange-text {
color: black;
}
</style>
<h1 class="red-text">I am red!</h1>
<h1 class="green-text">I am green!</h1>
<h1 class="dodger-blue-text">I am dodger blue!</h1>
<h1 class="orange-text">I am orange!</h1>
```
# --solutions--
```html
<style>
.red-text {
color: #FF0000;
}
.green-text {
color: #00FF00;
}
.dodger-blue-text {
color: #1E90FF;
}
.orange-text {
color: #FFA500;
}
</style>
<h1 class="red-text">I am red!</h1>
<h1 class="green-text">I am green!</h1>
<h1 class="dodger-blue-text">I am dodger blue!</h1>
<h1 class="orange-text">I am orange!</h1>
```

View File

@ -0,0 +1,140 @@
---
id: bad82fee1348bd9aedf08721
title: RGB を使用して色を調整する
challengeType: 0
videoUrl: 'https://scrimba.com/c/cm24JU6'
forumTopicId: 18368
dashedName: use-rgb-to-mix-colors
---
# --description--
16 進数コードと同様に、RGB でも異なる値を組み合わせて色を混ぜることができます。
# --instructions--
`style` 要素の中の 16 進数カラーコードを正しい RGB 値で置き換えてください。
<table class='table table-striped'><tbody><tr><th></th><th>RGB</th></tr><tr><td></td><td><code>rgb(0, 0, 255)</code></td></tr><tr><td></td><td><code>rgb(255, 0, 0)</code></td></tr><tr><td>オーキッド</td><td><code>rgb(218, 112, 214)</code></td></tr><tr><td>シエナ</td><td><code>rgb(160, 82, 45)</code></td></tr></tbody></table>
# --hints--
テキストが `I am red!``h1` 要素の `color` は赤にしてください。
```js
assert($('.red-text').css('color') === 'rgb(255, 0, 0)');
```
赤色の指定には `rgb` を使用してください。
```js
assert(
code.match(
/\.red-text\s*{\s*color\s*:\s*rgb\(\s*255\s*,\s*0\s*,\s*0\s*\)\s*;?\s*}/gi
)
);
```
テキストが `I am orchid!``h1` 要素の `color` はオーキッドにしてください。
```js
assert($('.orchid-text').css('color') === 'rgb(218, 112, 214)');
```
オーキッドの指定には `rgb` を使用してください。
```js
assert(
code.match(
/\.orchid-text\s*{\s*color\s*:\s*rgb\(\s*218\s*,\s*112\s*,\s*214\s*\)\s*;?\s*}/gi
)
);
```
テキストが `I am blue!``h1` 要素の `color` は青にしてください。
```js
assert($('.blue-text').css('color') === 'rgb(0, 0, 255)');
```
青色の指定には `rgb` を使用してください。
```js
assert(
code.match(
/\.blue-text\s*{\s*color\s*:\s*rgb\(\s*0\s*,\s*0\s*,\s*255\s*\)\s*;?\s*}/gi
)
);
```
テキストが `I am sienna!``h1` 要素の `color` はシエナにしてください。
```js
assert($('.sienna-text').css('color') === 'rgb(160, 82, 45)');
```
シエナの指定には `rgb` を使用してください。
```js
assert(
code.match(
/\.sienna-text\s*{\s*color\s*:\s*rgb\(\s*160\s*,\s*82\s*,\s*45\s*\)\s*;?\s*}/gi
)
);
```
# --seed--
## --seed-contents--
```html
<style>
.red-text {
color: #000000;
}
.orchid-text {
color: #000000;
}
.sienna-text {
color: #000000;
}
.blue-text {
color: #000000;
}
</style>
<h1 class="red-text">I am red!</h1>
<h1 class="orchid-text">I am orchid!</h1>
<h1 class="sienna-text">I am sienna!</h1>
<h1 class="blue-text">I am blue!</h1>
```
# --solutions--
```html
<style>
.red-text {
color: rgb(255, 0, 0);
}
.orchid-text {
color: rgb(218, 112, 214);
}
.sienna-text {
color: rgb(160, 82, 45);
}
.blue-text {
color:rgb(0, 0, 255);
}
</style>
<h1 class="red-text">I am red!</h1>
<h1 class="orchid-text">I am orchid!</h1>
<h1 class="sienna-text">I am sienna!</h1>
<h1 class="blue-text">I am blue!</h1>
```

View File

@ -0,0 +1,76 @@
---
id: bad87fee1348bd9aede08718
title: 要素の色指定に RGB 値を使用する
challengeType: 0
videoUrl: 'https://scrimba.com/c/cRkp2fr'
forumTopicId: 18369
dashedName: use-rgb-values-to-color-elements
---
# --description--
CSS で色を表現するもう一つの方法は、`RGB` の値を使用することです。
黒の `RGB` の値は以下のようになります:
```css
rgb(0, 0, 0)
```
白の `RGB` の値は以下のようになります:
```css
rgb(255, 255, 255)
```
6 桁の 16 進数を使う代わりに、`RGB` ではそれぞれの色の明るさを 0 から 255 の数字で指定します。
計算してみると、1 色を表す 16 進数 2 桁は 16×16 と等しく、合計 256 通りの値となることが分かります。 したがって、0 から数え始める `RGB` の取り得る値は、16 進数コードの場合と全く同じ数になります。
RGB コードを使用して `body` の背景をオレンジに変更する例を以下に示します。
```css
body {
background-color: rgb(255, 165, 0);
}
```
# --instructions--
`body` 要素の背景色の 16 進数コードを、黒を表す RGB 値 `rgb(0, 0, 0)` に置き換えましょう。
# --hints--
`body` 要素の背景は黒になるはずです。
```js
assert($('body').css('background-color') === 'rgb(0, 0, 0)');
```
`body` 要素の背景色を黒にするために `rgb` を使用してください。
```js
assert(code.match(/rgb\s*\(\s*0\s*,\s*0\s*,\s*0\s*\)/gi));
```
# --seed--
## --seed-contents--
```html
<style>
body {
background-color: #F00;
}
</style>
```
# --solutions--
```html
<style>
body {
background-color: rgb(0, 0, 0);
}
</style>
```