chore(curriculum): Remove files in wrong format

This commit is contained in:
Bouncey
2018-10-04 14:37:37 +01:00
committed by Stuart Taylor
parent 61222b1fb6
commit 8f39bc1288
2947 changed files with 118541 additions and 212907 deletions

View File

@ -0,0 +1,90 @@
---
id: bad87fee1348bd9aedf08823
title: Add a Negative Margin to an Element
challengeType: 0
guideUrl: 'https://guide.freecodecamp.org/certificates/add-a-negative-margin-to-an-element'
videoUrl: 'https://scrimba.com/c/cnpyGs3'
---
## Description
<section id='description'>
An element's <code>margin</code> controls the amount of space between an element's <code>border</code> and surrounding elements.
If you set an element's <code>margin</code> to a negative value, the element will grow larger.
</section>
## Instructions
<section id='instructions'>
Try to set the <code>margin</code> to a negative value like the one for the red box.
Change the <code>margin</code> of the blue box to <code>-15px</code>, so it fills the entire horizontal width of the yellow box around it.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Your <code>blue-box</code> class should give elements <code>-15px</code> of <code>margin</code>.
testString: 'assert($(".blue-box").css("margin-top") === "-15px", ''Your <code>blue-box</code> class should give elements <code>-15px</code> of <code>margin</code>.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,114 @@
---
id: bad87fee1348bd9bedf08813
title: Add Borders Around Your Elements
challengeType: 0
guideUrl: 'https://guide.freecodecamp.org/certificates/add-borders-around-your-elements'
videoUrl: 'https://scrimba.com/c/c2MvnHZ'
---
## Description
<section id='description'>
CSS borders have properties like <code>style</code>, <code>color</code> and <code>width</code>
For example, if we wanted to create a red, 5 pixel border around an HTML element, we could use this class:
<blockquote>&#60;style&#62;<br>&nbsp;&nbsp;.thin-red-border {<br>&nbsp;&nbsp;&nbsp;&nbsp;border-color: red;<br>&nbsp;&nbsp;&nbsp;&nbsp;border-width: 5px;<br>&nbsp;&nbsp;&nbsp;&nbsp;border-style: solid;<br>&nbsp;&nbsp;}<br>&#60;/style&#62;</blockquote>
</section>
## Instructions
<section id='instructions'>
Create a class called <code>thick-green-border</code>. This class should add a 10px, solid, green border around an HTML element. Apply the class to your cat photo.
Remember that you can apply multiple classes to an element using its <code>class</code> attribute, by separating each class name with a space. For example:
<code>&lt;img class="class1 class2"&gt;</code>
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Your <code>img</code> element should have the class <code>smaller-image</code>.
testString: 'assert($("img").hasClass("smaller-image"), ''Your <code>img</code> element should have the class <code>smaller-image</code>.'');'
- text: Your <code>img</code> element should have the class <code>thick-green-border</code>.
testString: 'assert($("img").hasClass("thick-green-border"), ''Your <code>img</code> element should have the class <code>thick-green-border</code>.'');'
- text: Give your image a border width of <code>10px</code>.
testString: 'assert($("img").hasClass("thick-green-border") && parseInt($("img").css("border-top-width"), 10) >= 8 && parseInt($("img").css("border-top-width"), 10) <= 12, ''Give your image a border width of <code>10px</code>.'');'
- text: Give your image a border style of <code>solid</code>.
testString: 'assert($("img").css("border-right-style") === "solid", ''Give your image a border style of <code>solid</code>.'');'
- text: The border around your <code>img</code> element should be green.
testString: 'assert($("img").css("border-left-color") === "rgb(0, 128, 0)", ''The border around your <code>img</code> element should be green.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```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://bit.ly/fcc-relaxing-cat" 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="/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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,95 @@
---
id: bad87fee1248bd9aedf08824
title: Add Different Margins to Each Side of an Element
challengeType: 0
videoUrl: 'https://scrimba.com/c/cg4RWh4'
---
## Description
<section id='description'>
Sometimes you will want to customize an element so that it has a different <code>margin</code> on each of its sides.
CSS allows you to control the <code>margin</code> of all four individual sides of an element with the <code>margin-top</code>, <code>margin-right</code>, <code>margin-bottom</code>, and <code>margin-left</code> properties.
</section>
## Instructions
<section id='instructions'>
Give the blue box a <code>margin</code> of <code>40px</code> on its top and left side, but only <code>20px</code> on its bottom and right side.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Your <code>blue-box</code> class should give the top of elements <code>40px</code> of <code>margin</code>.
testString: 'assert($(".blue-box").css("margin-top") === "40px", ''Your <code>blue-box</code> class should give the top of elements <code>40px</code> of <code>margin</code>.'');'
- text: Your <code>blue-box</code> class should give the right of elements <code>20px</code> of <code>margin</code>.
testString: 'assert($(".blue-box").css("margin-right") === "20px", ''Your <code>blue-box</code> class should give the right of elements <code>20px</code> of <code>margin</code>.'');'
- text: Your <code>blue-box</code> class should give the bottom of elements <code>20px</code> of <code>margin</code>.
testString: 'assert($(".blue-box").css("margin-bottom") === "20px", ''Your <code>blue-box</code> class should give the bottom of elements <code>20px</code> of <code>margin</code>.'');'
- text: Your <code>blue-box</code> class should give the left of elements <code>40px</code> of <code>margin</code>.
testString: 'assert($(".blue-box").css("margin-left") === "40px", ''Your <code>blue-box</code> class should give the left of elements <code>40px</code> of <code>margin</code>.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,96 @@
---
id: bad87fee1348bd9aedf08824
title: Add Different Padding to Each Side of an Element
challengeType: 0
guideUrl: 'https://guide.freecodecamp.org/certificates/add-different-padding-to-each-side-of-an-element'
videoUrl: 'https://scrimba.com/c/cB7mwUw'
---
## Description
<section id='description'>
Sometimes you will want to customize an element so that it has different amounts of <code>padding</code> on each of its sides.
CSS allows you to control the <code>padding</code> of all four individual sides of an element with the <code>padding-top</code>, <code>padding-right</code>, <code>padding-bottom</code>, and <code>padding-left</code> properties.
</section>
## Instructions
<section id='instructions'>
Give the blue box a <code>padding</code> of <code>40px</code> on its top and left side, but only <code>20px</code> on its bottom and right side.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Your <code>blue-box</code> class should give the top of the elements <code>40px</code> of <code>padding</code>.
testString: 'assert($(".blue-box").css("padding-top") === "40px", ''Your <code>blue-box</code> class should give the top of the elements <code>40px</code> of <code>padding</code>.'');'
- text: Your <code>blue-box</code> class should give the right of the elements <code>20px</code> of <code>padding</code>.
testString: 'assert($(".blue-box").css("padding-right") === "20px", ''Your <code>blue-box</code> class should give the right of the elements <code>20px</code> of <code>padding</code>.'');'
- text: Your <code>blue-box</code> class should give the bottom of the elements <code>20px</code> of <code>padding</code>.
testString: 'assert($(".blue-box").css("padding-bottom") === "20px", ''Your <code>blue-box</code> class should give the bottom of the elements <code>20px</code> of <code>padding</code>.'');'
- text: Your <code>blue-box</code> class should give the left of the elements <code>40px</code> of <code>padding</code>.
testString: 'assert($(".blue-box").css("padding-left") === "40px", ''Your <code>blue-box</code> class should give the left of the elements <code>40px</code> of <code>padding</code>.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,111 @@
---
id: bad87fee1348bd9aedf08814
title: Add Rounded Corners with border-radius
challengeType: 0
guideUrl: 'https://guide.freecodecamp.org/certificates/add-rounded-corners-a-border-radius'
videoUrl: 'https://scrimba.com/c/cbZm2hg'
---
## Description
<section id='description'>
Your cat photo currently has sharp corners. We can round out those corners with a CSS property called <code>border-radius</code>.
</section>
## Instructions
<section id='instructions'>
You can specify a <code>border-radius</code> with pixels. Give your cat photo a <code>border-radius</code> of <code>10px</code>.
Note: this challenge allows for multiple possible solutions. For example, you may add <code>border-radius</code> to either the <code>.thick-green-border</code> class or the <code>.smaller-image</code> class.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Your image element should have the class "thick-green-border".
testString: 'assert($("img").hasClass("thick-green-border"), ''Your image element should have the class "thick-green-border".'');'
- text: Your image should have a border radius of <code>10px</code>
testString: 'assert(parseInt($("img").css("border-top-left-radius")) > 8, ''Your image should have a border radius of <code>10px</code>'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```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://bit.ly/fcc-relaxing-cat" 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="/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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,91 @@
---
id: bad87fee1348bd9aedf08822
title: Adjust the Margin of an Element
challengeType: 0
guideUrl: 'https://guide.freecodecamp.org/certificates/adjust-the-margin-of-an-element'
videoUrl: 'https://scrimba.com/c/cVJarHW'
---
## Description
<section id='description'>
An element's <code>margin</code> controls the amount of space between an element's <code>border</code> and surrounding elements.
Here, we can see that the blue box and the red box are nested within the yellow box. Note that the red box has a bigger <code>margin</code> than the blue box, making it appear smaller.
When you increase the blue box's <code>margin</code>, it will increase the distance between its border and surrounding elements.
</section>
## Instructions
<section id='instructions'>
Change the <code>margin</code> of the blue box to match that of the red box.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Your <code>blue-box</code> class should give elements <code>20px</code> of <code>margin</code>.
testString: 'assert($(".blue-box").css("margin-top") === "20px", ''Your <code>blue-box</code> class should give elements <code>20px</code> of <code>margin</code>.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,92 @@
---
id: bad88fee1348bd9aedf08825
title: Adjust the Padding of an Element
challengeType: 0
guideUrl: 'https://guide.freecodecamp.org/certificates/adjust-the-padding-of-an-element'
videoUrl: 'https://scrimba.com/c/cED8ZC2'
---
## Description
<section id='description'>
Now let's put our Cat Photo App away for a little while and learn more about styling HTML.
You may have already noticed this, but all HTML elements are essentially little rectangles.
Three important properties control the space that surrounds each HTML element: <code>padding</code>, <code>margin</code>, and <code>border</code>.
An element's <code>padding</code> controls the amount of space between the element's content and its <code>border</code>.
Here, we can see that the blue box and the red box are nested within the yellow box. Note that the red box has more <code>padding</code> than the blue box.
When you increase the blue box's <code>padding</code>, it will increase the distance(<code>padding</code>) between the text and the border around it.
</section>
## Instructions
<section id='instructions'>
Change the <code>padding</code> of your blue box to match that of your red box.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Your <code>blue-box</code> class should give elements <code>20px</code> of <code>padding</code>.
testString: 'assert($(".blue-box").css("padding-top") === "20px", ''Your <code>blue-box</code> class should give elements <code>20px</code> of <code>padding</code>.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,263 @@
---
id: 5a9d7286424fe3d0e10cad13
title: Attach a Fallback value to a CSS Variable
challengeType: 0
videoUrl: 'https://scrimba.com/c/c6bDNfp'
---
## Description
<section id='description'>
When using your variable as a CSS property value, you can attach a fallback value that your browser will revert to if the given variable is invalid.
<strong>Note:</strong> This fallback is not used to increase browser compatibilty, and it will not work on IE browsers. Rather, it is used so that the browser has a color to display if it cannot find your variable.
Here's how you do it:
<blockquote>background: var(--penguin-skin, black);</blockquote>
This will set background to black if your variable wasn't set.
Note that this can be useful for debugging.
</section>
## Instructions
<section id='instructions'>
It looks there is a problem with the variables supplied to the <code>.penguin-top</code> and <code>.penguin-bottom</code> classes. Rather than fix the typo, add a fallback value of <code>black</code> to the <code>background</code> property of the <code>.penguin-top</code> and <code>.penguin-bottom</code> classes.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Apply the fallback value of <code>black</code> to the <code>background</code> property of the <code>penguin-top</code> class.
testString: '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), ''Apply the fallback value of <code>black</code> to the <code>background</code> property of the <code>penguin-top</code> class.'');'
- text: Apply the fallback value of <code>black</code> to the <code>background</code> property of the <code>penguin-bottom</code> class.
testString: 'assert(code.match(/.penguin-bottom\s*?{[\s\S]*background\s*?:\s*?var\(\s*?--pengiun-skin\s*?,\s*?black\s*?\)\s*?;[\s\S]*}/gi), ''Apply the fallback value of <code>black</code> to the <code>background</code> property of the <code>penguin-bottom</code> class.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```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 */
background: var(--pengiun-skin);
/* change code above */
width: 50%;
height: 45%;
border-radius: 70% 70% 60% 60%;
}
.penguin-bottom {
top: 40%;
left: 23.5%;
/* change code below */
background: var(--pengiun-skin);
/* change code above */
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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
var code = ".penguin-top {background: var(--pengiun-skin, black);} .penguin-bottom {background: var(--pengiun-skin, black);}"
```
</section>

View File

@ -0,0 +1,256 @@
---
id: 5a9d7295424fe3d0e10cad14
title: Cascading CSS variables
challengeType: 0
videoUrl: 'https://scrimba.com/c/cyLZZhZ'
---
## Description
<section id='description'>
When you create a variable, it becomes available for you to use inside the element in which you create it. It also becomes available within any elements nested within it. This effect is known as <dfn>cascading</dfn>.
Because of cascading, CSS variables are often defined in the <dfn>:root</dfn> element.
<code>:root</code> is a <dfn>pseudo-class</dfn> selector that matches the root element of the document, usually the <code><html></code> element. By creating your variables in <code>:root</code>, they will be available globally and can be accessed from any other selector later in the style sheet.
</section>
## Instructions
<section id='instructions'>
Define a variable named <code>--penguin-belly</code> in the <code>:root</code> selector and give it the value of <code>pink</code>. You can then see how the value will cascade down to change the value to pink, anywhere that variable is used.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: 'declare the <code>--penguin-belly</code> variable in the <code>:root</code> and assign it to <code>pink</code>.'
testString: 'assert(code.match(/:root\s*?{[\s\S]*--penguin-belly\s*?:\s*?pink\s*?;[\s\S]*}/gi), ''declare the <code>--penguin-belly</code> variable in the <code>:root</code> and assign it to <code>pink</code>.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```html
<style>
:root {
/* add code below */
/* add code above */
}
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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
var code = ":root {--penguin-belly: pink;}"
```
</section>

View File

@ -0,0 +1,257 @@
---
id: 5a9d72a1424fe3d0e10cad15
title: Change a variable for a specific area
challengeType: 0
videoUrl: 'https://scrimba.com/c/cdRwbuW'
---
## Description
<section id='description'>
When you create your variables in <code>:root</code> they will set the value of that variable for the whole page.
You can then over-write these variables by setting them again within a specific element.
</section>
## Instructions
<section id='instructions'>
Change the value of <code>--penguin-belly</code> to <code>white</code> in the <code>penguin</code> class.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: The <code>penguin</code> class should reassign the <code>--penguin-belly</code> variable to <code>white</code>.
testString: 'assert(code.match(/.penguin\s*?{[\s\S]*--penguin-belly\s*?:\s*?white\s*?;[\s\S]*}/gi), ''The <code>penguin</code> class should reassign the <code>--penguin-belly</code> variable to <code>white</code>.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```html
<style>
:root {
--penguin-skin: gray;
--penguin-belly: pink;
--penguin-beak: orange;
}
body {
background: var(--penguin-belly, #c6faf1);
}
.penguin {
/* add code below */
/* add code above */
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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
var code = ".penguin {--penguin-belly: white;}"
```
</section>

View File

@ -0,0 +1,88 @@
---
id: bad87fee1348bd9aedf08803
title: Change the Color of Text
challengeType: 0
videoUrl: 'https://scrimba.com/c/cRkVmSm'
---
## Description
<section id='description'>
Now let's change the color of some of our text.
We can do this by changing the <code>style</code> of your <code>h2</code> element.
The property that is responsible for the color of an element's text is the <code>color</code> style property.
Here's how you would set your <code>h2</code> element's text color to blue:
<code>&#60;h2 style="color: blue;"&#62;CatPhotoApp&#60;/h2&#62;</code>
Note that it is a good practice to end inline <code>style</code> declarations with a <code>;</code> .
</section>
## Instructions
<section id='instructions'>
Change your <code>h2</code> element's style so that its text color is red.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Your <code>h2</code> element should be red.
testString: 'assert($("h2").css("color") === "rgb(255, 0, 0)", ''Your <code>h2</code> element should be red.'');'
- text: Your <code>style</code> declaration should end with a <code>;</code> .
testString: 'assert(code.match(/<h2\s+style\s*=\s*(\''|")\s*color\s*:\s*(?:rgb\(\s*255\s*,\s*0\s*,\s*0\s*\)|rgb\(\s*100%\s*,\s*0%\s*,\s*0%\s*\)|red|#ff0000|#f00|hsl\(\s*0\s*,\s*100%\s*,\s*50%\s*\))\s*\;(\''|")>\s*CatPhotoApp\s*<\/h2>/),'' Your <code>style</code> declaration should end with a <code>;</code> .'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```html
<h2>CatPhotoApp</h2>
<main>
<p>Click here to view more <a href="#">cat photos</a>.</p>
<a href="#"><img src="https://bit.ly/fcc-relaxing-cat" 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="/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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,88 @@
---
id: bad87fee1348bd9aedf08806
title: Change the Font Size of an Element
challengeType: 0
videoUrl: 'https://scrimba.com/c/c3bvDc8'
---
## Description
<section id='description'>
Font size is controlled by the <code>font-size</code> CSS property, like this:
<blockquote>h1 {<br>&nbsp;&nbsp;font-size: 30px;<br>}</blockquote>
</section>
## Instructions
<section id='instructions'>
Inside the same <code>&#60;style&#62;</code> tag that contains your <code>red-text</code> class, create an entry for <code>p</code> elements and set the <code>font-size</code> to 16 pixels (<code>16px</code>).
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: 'Between the <code>style</code> tags, give the <code>p</code> elements <code>font-size</code> of <code>16px</code>. Browser and Text zoom should be at 100%.'
testString: 'assert(code.match(/p\s*{\s*font-size\s*:\s*16\s*px\s*;\s*}/i), ''Between the <code>style</code> tags, give the <code>p</code> elements <code>font-size</code> of <code>16px</code>. Browser and Text zoom should be at 100%.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```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://bit.ly/fcc-relaxing-cat" 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="/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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,252 @@
---
id: 5a9d726c424fe3d0e10cad11
title: Create a custom CSS Variable
challengeType: 0
videoUrl: 'https://scrimba.com/c/cQd27Hr'
---
## Description
<section id='description'>
To create a CSS Variable, you just need to give it a <code>name</code> with <code>two dashes</code> in front of it and assign it a <code>value</code> like this:
<blockquote>--penguin-skin: gray;</blockquote>
This will create a variable named <code>--penguin-skin</code> and assign it the value of <code>gray</code>.
Now you can use that variable elsewhere in your CSS to change the value of other elements to gray.
</section>
## Instructions
<section id='instructions'>
In the <code>penguin</code> class, create a variable name <code>--penguin-skin</code> and give it a value of <code>gray</code>
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>penguin</code> class should declare the <code>--penguin-skin</code> variable and assign it to <code>gray</code>.
testString: 'assert(code.match(/.penguin\s*?{[\s\S]*--penguin-skin\s*?:\s*?gray\s*?;[\s\S]*}/gi), ''<code>penguin</code> class should declare the <code>--penguin-skin</code> variable and assign it to <code>gray</code>.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```html
<style>
.penguin {
/* add code below */
/* add code above */
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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
var code = ".penguin {--penguin-skin: gray;}"
```
</section>

View File

@ -0,0 +1,114 @@
---
id: bad87fed1348bd9aede07836
title: Give a Background Color to a div Element
challengeType: 0
videoUrl: 'https://scrimba.com/c/cdRKMCk'
---
## Description
<section id='description'>
You can set an element's background color with the <code>background-color</code> property.
For example, if you wanted an element's background color to be <code>green</code>, you'd put this within your <code>style</code> element:
<blockquote>.green-background {<br>&nbsp;&nbsp;background-color: green;<br>}</blockquote>
</section>
## Instructions
<section id='instructions'>
Create a class called <code>silver-background</code> with the <code>background-color</code> of silver. Assign this class to your <code>div</code> element.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Give your <code>div</code> element the class <code>silver-background</code>.
testString: 'assert($("div").hasClass("silver-background"), ''Give your <code>div</code> element the class <code>silver-background</code>.'');'
- text: Your <code>div</code> element should have a silver background.
testString: 'assert($("div").css("background-color") === "rgb(192, 192, 192)", ''Your <code>div</code> element should have a silver background.'');'
- text: Define a class named <code>silver-background</code> within the <code>style</code> element and assign the value of <code>silver</code> to the <code>background-color</code> property.
testString: 'assert(code.match(/\.silver-background\s*{\s*background-color:\s*silver;\s*}/), "Define a class named <code>silver-background</code> within the <code>style</code> element and assign the value of <code>silver</code> to the <code>background-color</code> property.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```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://bit.ly/fcc-relaxing-cat" 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="/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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,105 @@
---
id: bad87fee1348bd9aedf08807
title: Import a Google Font
challengeType: 0
videoUrl: 'https://scrimba.com/c/cM9MRsJ'
---
## Description
<section id='description'>
In addition to specifying common fonts that are found on most operating systems, we can also specify non-standard, custom web fonts for use on our website. There are various sources for web fonts on the internet but, for this example we will focus on the Google Fonts library.
<a href='https://fonts.google.com/' target='_blank'>Google Fonts</a> is a free library of web fonts that you can use in your CSS by referencing the font's URL.
So, let's go ahead and import and apply a Google font (note that if Google is blocked in your country, you will need to skip this challenge).
To import a Google Font, you can copy the font(s) URL from the Google Fonts library and then paste it in your HTML. For this challenge, we'll import the <code>Lobster</code> font. To do this, copy the following code snippet and paste it into the top of your code editor(before the opening <code>style</code> element):
<code>&#60;link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css"&#62;</code>
Now you can use the <code>Lobster</code> font in your CSS by using <code>Lobster</code> as the FAMILY_NAME as in the following example:<br><code>font-family: FAMILY_NAME, GENERIC_NAME;</code>.
The GENERIC_NAME is optional, and is a fallback font in case the other specified font is not available. This is covered in the next challenge.
Family names are case-sensitive and need to be wrapped in quotes if there is a space in the name. For example, you need quotes to use the <code>"Open Sans"</code> font, but not to use the <code>Lobster</code> font.
</section>
## Instructions
<section id='instructions'>
Create a <code>font-family</code> CSS rule that uses the <code>Lobster</code> font, and ensure that it will be applied to your <code>h2</code> element.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Import the <code>Lobster</code> font.
testString: 'assert(new RegExp("googleapis", "gi").test(code), ''Import the <code>Lobster</code> font.'');'
- text: Your <code>h2</code> element should use the font <code>Lobster</code>.
testString: 'assert($("h2").css("font-family").match(/lobster/i), ''Your <code>h2</code> element should use the font <code>Lobster</code>.'');'
- text: Use an <code>h2</code> CSS selector to change the font.
testString: 'assert(/\s*h2\s*\{\s*font-family\:\s*(\''|")?Lobster(\''|")?\s*;\s*\}/gi.test(code), ''Use an <code>h2</code> CSS selector to change the font.'');'
- text: Your <code>p</code> element should still use the font <code>monospace</code>.
testString: 'assert($("p").css("font-family").match(/monospace/i), ''Your <code>p</code> element should still use the font <code>monospace</code>.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```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://bit.ly/fcc-relaxing-cat" 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="/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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,66 @@
---
id: 5b7d72c338cd7e35b63f3e14
title: Improve Compatibility with Browser Fallbacks
challengeType: 0
videoUrl: ''
---
## Description
<section id='description'>
When working with CSS you will likely run into browser compatibility issues at some point. This is why it's important to provide browser fallbacks to avoid potential problems.
When your browser parses the CSS of a webpage, it ignores any properties that it doesn't recognize or support. For example, if you use a CSS variable to assign a background color on a site, Internet Explorer will ignore the background color because it does not support CSS variables. In that case, the browser will use whatever value it has for that property. If it can't find any other value set for that property, it will revert to the default value, which is typically not ideal.
This means that if you do want to provide a browser fallback, it's as easy as providing another more widely supported value immediately before your declaration. That way an older browser will have something to fall back on, while a newer browser will just interpret whatever declaration comes later in the cascade.
</section>
## Instructions
<section id='instructions'>
It looks like a variable is being used to set the background color of the <code>.red-box</code> class. Let's improve our browser compatibility by adding another <code>background</code> declaration right before the existing declaration and set its value to red.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Your <code>.red-box</code> rule should include a fallback with the <code>background</code> set to red immediately before the existing <code>background</code> declaration.
testString: 'assert(code.match(/.red-box\s*{[^}]*background:\s*(red|#ff0000|#f00|rgb\(\s*255\s*,\s*0\s*,\s*0\s*\)|rgb\(\s*100%\s*,\s*0%\s*,\s*0%\s*\)|hsl\(\s*0\s*,\s*100%\s*,\s*50%\s*\))\s*;\s*background:\s*var\(\s*--red-color\s*\);/gi), ''Your <code>.red-box</code> rule should include a fallback with the <code>background</code> set to red immediately before the existing <code>background</code> declaration.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```html
<style>
:root {
--red-color: red;
}
.red-box {
background: var(--red-color);
height: 200px;
width:200px;
}
</style>
<div class="red-box"></div>
```
</div>
</section>
## Solution
<section id='solution'>
```js
var code=".red-box {background: red; background: var(--red-color);}"
```
</section>

View File

@ -0,0 +1,71 @@
---
id: bad87fee1348bd9aedf08746
title: Inherit Styles from the Body Element
challengeType: 0
videoUrl: 'https://scrimba.com/c/c9bmdtR'
---
## Description
<section id='description'>
Now we've proven that every HTML page has a <code>body</code> element, and that its <code>body</code> element can also be styled with CSS.
Remember, you can style your <code>body</code> element just like any other HTML element, and all your other elements will inherit your <code>body</code> element's styles.
</section>
## Instructions
<section id='instructions'>
First, create a <code>h1</code> element with the text <code>Hello World</code>
Then, let's give all elements on your page the color of <code>green</code> by adding <code>color: green;</code> to your <code>body</code> element's style declaration.
Finally, give your <code>body</code> element the font-family of <code>monospace</code> by adding <code>font-family: monospace;</code> to your <code>body</code> element's style declaration.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Create an <code>h1</code> element.
testString: 'assert(($("h1").length > 0), ''Create an <code>h1</code> element.'');'
- text: Your <code>h1</code> element should have the text <code>Hello World</code>.
testString: 'assert(($("h1").length > 0 && $("h1").text().match(/hello world/i)), ''Your <code>h1</code> element should have the text <code>Hello World</code>.'');'
- text: Make sure your <code>h1</code> element has a closing tag.
testString: 'assert(code.match(/<\/h1>/g) && code.match(/<h1/g) && code.match(/<\/h1>/g).length === code.match(/<h1/g).length, ''Make sure your <code>h1</code> element has a closing tag.'');'
- text: Give your <code>body</code> element the <code>color</code> property of <code>green</code>.
testString: 'assert(($("body").css("color") === "rgb(0, 128, 0)"), ''Give your <code>body</code> element the <code>color</code> property of <code>green</code>.'');'
- text: Give your <code>body</code> element the <code>font-family</code> property of <code>monospace</code>.
testString: 'assert(($("body").css("font-family").match(/monospace/i)), ''Give your <code>body</code> element the <code>font-family</code> property of <code>monospace</code>.'');'
- text: Your <code>h1</code> element should inherit the font <code>monospace</code> from your <code>body</code> element.
testString: 'assert(($("h1").length > 0 && $("h1").css("font-family").match(/monospace/i)), ''Your <code>h1</code> element should inherit the font <code>monospace</code> from your <code>body</code> element.'');'
- text: Your <code>h1</code> element should inherit the color green from your <code>body</code> element.
testString: 'assert(($("h1").length > 0 && $("h1").css("color") === "rgb(0, 128, 0)"), ''Your <code>h1</code> element should inherit the color green from your <code>body</code> element.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```html
<style>
body {
background-color: black;
}
</style>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,110 @@
---
id: bad87fee1348bd9aedf08815
title: Make Circular Images with a border-radius
challengeType: 0
videoUrl: 'https://scrimba.com/c/c2MvrcB'
---
## Description
<section id='description'>
In addition to pixels, you can also specify the <code>border-radius</code> using a percentage.
</section>
## Instructions
<section id='instructions'>
Give your cat photo a <code>border-radius</code> of <code>50%</code>.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: 'Your image should have a border radius of <code>50%</code>, making it perfectly circular.'
testString: 'assert(parseInt($("img").css("border-top-left-radius")) > 48, ''Your image should have a border radius of <code>50%</code>, making it perfectly circular.'');'
- text: Be sure to use a percentage value of <code>50%</code>.
testString: 'assert(code.match(/50%/g), ''Be sure to use a percentage value of <code>50%</code>.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```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://bit.ly/fcc-relaxing-cat" 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="/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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,190 @@
{
"name": "Basic CSS",
"dashedName": "basic-css",
"order": 1,
"time": "5 hours",
"template": "",
"required": [],
"superBlock": "responsive-web-design",
"superOrder": 1,
"challengeOrder": [
[
"bad87fee1348bd9aedf08803",
"Change the Color of Text"
],
[
"bad87fee1348bd9aedf08805",
"Use CSS Selectors to Style Elements"
],
[
"bad87fee1348bd9aecf08806",
"Use a CSS Class to Style an Element"
],
[
"bad87fee1348bd9aefe08806",
"Style Multiple Elements with a CSS Class"
],
[
"bad87fee1348bd9aedf08806",
"Change the Font Size of an Element"
],
[
"bad87fee1348bd9aede08807",
"Set the Font Family of an Element"
],
[
"bad87fee1348bd9aedf08807",
"Import a Google Font"
],
[
"bad87fee1348bd9aedf08808",
"Specify How Fonts Should Degrade"
],
[
"bad87fee1348bd9acdf08812",
"Size Your Images"
],
[
"bad87fee1348bd9bedf08813",
"Add Borders Around Your Elements"
],
[
"bad87fee1348bd9aedf08814",
"Add Rounded Corners with border-radius"
],
[
"bad87fee1348bd9aedf08815",
"Make Circular Images with a border-radius"
],
[
"bad87fed1348bd9aede07836",
"Give a Background Color to a div Element"
],
[
"bad87eee1348bd9aede07836",
"Set the id of an Element"
],
[
"bad87dee1348bd9aede07836",
"Use an id Attribute to Style an Element"
],
[
"bad88fee1348bd9aedf08825",
"Adjust the Padding of an Element"
],
[
"bad87fee1348bd9aedf08822",
"Adjust the Margin of an Element"
],
[
"bad87fee1348bd9aedf08823",
"Add a Negative Margin to an Element"
],
[
"bad87fee1348bd9aedf08824",
"Add Different Padding to Each Side of an Element"
],
[
"bad87fee1248bd9aedf08824",
"Add Different Margins to Each Side of an Element"
],
[
"bad87fee1348bd9aedf08826",
"Use Clockwise Notation to Specify the Padding of an Element"
],
[
"bad87fee1348bd9afdf08726",
"Use Clockwise Notation to Specify the Margin of an Element"
],
[
"58c383d33e2e3259241f3076",
"Use Attribute Selectors to Style Elements"
],
[
"bad82fee1322bd9aedf08721",
"Understand Absolute versus Relative Units"
],
[
"bad87fee1348bd9aedf08736",
"Style the HTML Body Element"
],
[
"bad87fee1348bd9aedf08746",
"Inherit Styles from the Body Element"
],
[
"bad87fee1348bd9aedf08756",
"Prioritize One Style Over Another"
],
[
"bad87fee1348bd9aedf04756",
"Override Styles in Subsequent CSS"
],
[
"bad87fee1348bd8aedf06756",
"Override Class Declarations by Styling ID Attributes"
],
[
"bad87fee1348bd9aedf06756",
"Override Class Declarations with Inline Styles"
],
[
"bad87fee1348bd9aedf07756",
"Override All Other Styles by using Important"
],
[
"bad87fee1348bd9aedf08726",
"Use Hex Code for Specific Colors"
],
[
"bad87fee1348bd9aedf08721",
"Use Hex Code to Mix Colors"
],
[
"bad87fee1348bd9aedf08719",
"Use Abbreviated Hex Code"
],
[
"bad87fee1348bd9aede08718",
"Use RGB values to Color Elements"
],
[
"bad82fee1348bd9aedf08721",
"Use RGB to Mix Colors"
],
[
"5a9d725e424fe3d0e10cad10",
"Use CSS Variables to change several elements at once"
],
[
"5a9d726c424fe3d0e10cad11",
"Create a custom CSS Variable"
],
[
"5a9d727a424fe3d0e10cad12",
"Use a custom CSS Variable"
],
[
"5a9d7286424fe3d0e10cad13",
"Attach a Fallback value to a CSS Variable"
],
[
"5b7d72c338cd7e35b63f3e14",
"Improve Compatibility with Browser Fallbacks"
],
[
"5a9d7295424fe3d0e10cad14",
"Cascading CSS variables"
],
[
"5a9d72a1424fe3d0e10cad15",
"Change a variable for a specific area"
],
[
"5a9d72ad424fe3d0e10cad16",
"Use a media query to change a variable"
]
],
"helpRoom": "Help",
"fileName": "01-responsive-web-design/basic-css.json"
}

View File

@ -0,0 +1,82 @@
---
id: bad87fee1348bd9aedf07756
title: Override All Other Styles by using Important
challengeType: 0
videoUrl: 'https://scrimba.com/c/cm24rcp'
---
## Description
<section id='description'>
Yay! We just proved that inline styles will override all the CSS declarations in your <code>style</code> element.
But wait. There's one last way to override CSS. This is the most powerful method of all. But before we do it, let's talk about why you would ever want to override CSS.
In many situations, you will use CSS libraries. These may accidentally override your own CSS. So when you absolutely need to be sure that an element has specific CSS, you can use <code>!important</code>
Let's go all the way back to our <code>pink-text</code> class declaration. Remember that our <code>pink-text</code> class was overridden by subsequent class declarations, id declarations, and inline styles.
</section>
## Instructions
<section id='instructions'>
Let's add the keyword <code>!important</code> to your pink-text element's color declaration to make 100% sure that your <code>h1</code> element will be pink.
An example of how to do this is:
<code>color: red !important;</code>
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Your <code>h1</code> element should have the class <code>pink-text</code>.
testString: 'assert($("h1").hasClass("pink-text"), ''Your <code>h1</code> element should have the class <code>pink-text</code>.'');'
- text: Your <code>h1</code> element should have the class <code>blue-text</code>.
testString: 'assert($("h1").hasClass("blue-text"), ''Your <code>h1</code> element should have the class <code>blue-text</code>.'');'
- text: Your <code>h1</code> element should have the id of <code>orange-text</code>.
testString: 'assert($("h1").attr("id") === "orange-text", ''Your <code>h1</code> element should have the id of <code>orange-text</code>.'');'
- text: 'Your <code>h1</code> element should have the inline style of <code>color&#58; white</code>.'
testString: 'assert(code.match(/<h1.*style/gi) && code.match(/<h1.*style.*color\s*?:/gi), ''Your <code>h1</code> element should have the inline style of <code>color&#58; white</code>.'');'
- text: Your <code>pink-text</code> class declaration should have the <code>!important</code> keyword to override all other declarations.
testString: 'assert(code.match(/\.pink-text\s*?\{[\s\S]*?color:.*pink.*!important\s*;?[^\.]*\}/g), ''Your <code>pink-text</code> class declaration should have the <code>!important</code> keyword to override all other declarations.'');'
- text: Your <code>h1</code> element should be pink.
testString: 'assert($("h1").css("color") === "rgb(255, 192, 203)", ''Your <code>h1</code> element should be pink.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,83 @@
---
id: bad87fee1348bd8aedf06756
title: Override Class Declarations by Styling ID Attributes
challengeType: 0
videoUrl: 'https://scrimba.com/c/cRkpDhB'
---
## Description
<section id='description'>
We just proved that browsers read CSS from top to bottom. That means that, in the event of a conflict, the browser will use whichever CSS declaration came last.
But we're not done yet. There are other ways that you can override CSS. Do you remember id attributes?
Let's override your <code>pink-text</code> and <code>blue-text</code> classes, and make your <code>h1</code> element orange, by giving the <code>h1</code> element an id and then styling that id.
</section>
## Instructions
<section id='instructions'>
Give your <code>h1</code> element the <code>id</code> attribute of <code>orange-text</code>. Remember, id styles look like this:
<code>&#60;h1 id="orange-text"&#62;</code>
Leave the <code>blue-text</code> and <code>pink-text</code> classes on your <code>h1</code> element.
Create a CSS declaration for your <code>orange-text</code> id in your <code>style</code> element. Here's an example of what this looks like:
<blockquote>#brown-text {<br>&nbsp;&nbsp;color: brown;<br>}</blockquote>
Note: It doesn't matter whether you declare this CSS above or below pink-text class, since id attribute will always take precedence.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Your <code>h1</code> element should have the class <code>pink-text</code>.
testString: 'assert($("h1").hasClass("pink-text"), ''Your <code>h1</code> element should have the class <code>pink-text</code>.'');'
- text: Your <code>h1</code> element should have the class <code>blue-text</code>.
testString: 'assert($("h1").hasClass("blue-text"), ''Your <code>h1</code> element should have the class <code>blue-text</code>.'');'
- text: Give your <code>h1</code> element the id of <code>orange-text</code>.
testString: 'assert($("h1").attr("id") === "orange-text", ''Give your <code>h1</code> element the id of <code>orange-text</code>.'');'
- text: There should be only one <code>h1</code> element.
testString: 'assert(($("h1").length === 1), ''There should be only one <code>h1</code> element.'');'
- text: Create a CSS declaration for your <code>orange-text</code> id
testString: 'assert(code.match(/#orange-text\s*{/gi), ''Create a CSS declaration for your <code>orange-text</code> id'');'
- text: Do not give your <code>h1</code> any <code>style</code> attributes.
testString: 'assert(!code.match(/<h1.*style.*>/gi), ''Do not give your <code>h1</code> any <code>style</code> attributes.'');'
- text: Your <code>h1</code> element should be orange.
testString: 'assert($("h1").css("color") === "rgb(255, 165, 0)", ''Your <code>h1</code> element should be orange.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,78 @@
---
id: bad87fee1348bd9aedf06756
title: Override Class Declarations with Inline Styles
challengeType: 0
videoUrl: 'https://scrimba.com/c/cGJDRha'
---
## Description
<section id='description'>
So we've proven that id declarations override class declarations, regardless of where they are declared in your <code>style</code> element CSS.
There are other ways that you can override CSS. Do you remember inline styles?
</section>
## Instructions
<section id='instructions'>
Use an <code>inline style</code> to try to make our <code>h1</code> element white. Remember, in line styles look like this:
<code>&#60;h1 style="color: green;"&#62;</code>
Leave the <code>blue-text</code> and <code>pink-text</code> classes on your <code>h1</code> element.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Your <code>h1</code> element should have the class <code>pink-text</code>.
testString: 'assert($("h1").hasClass("pink-text"), ''Your <code>h1</code> element should have the class <code>pink-text</code>.'');'
- text: Your <code>h1</code> element should have the class <code>blue-text</code>.
testString: 'assert($("h1").hasClass("blue-text"), ''Your <code>h1</code> element should have the class <code>blue-text</code>.'');'
- text: Your <code>h1</code> element should have the id of <code>orange-text</code>.
testString: 'assert($("h1").attr("id") === "orange-text", ''Your <code>h1</code> element should have the id of <code>orange-text</code>.'');'
- text: Give your <code>h1</code> element an inline style.
testString: 'assert(document.querySelector(''h1[style]''), ''Give your <code>h1</code> element an inline style.'');'
- text: Your <code>h1</code> element should be white.
testString: 'assert($("h1").css("color") === "rgb(255, 255, 255)", ''Your <code>h1</code> element should be white.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,73 @@
---
id: bad87fee1348bd9aedf04756
title: Override Styles in Subsequent CSS
challengeType: 0
videoUrl: 'https://scrimba.com/c/cGJDQug'
---
## Description
<section id='description'>
Our "pink-text" class overrode our <code>body</code> element's CSS declaration!
We just proved that our classes will override the <code>body</code> element's CSS. So the next logical question is, what can we do to override our <code>pink-text</code> class?
</section>
## Instructions
<section id='instructions'>
Create an additional CSS class called <code>blue-text</code> that gives an element the color blue. Make sure it's below your <code>pink-text</code> class declaration.
Apply the <code>blue-text</code> class to your <code>h1</code> element in addition to your <code>pink-text</code> class, and let's see which one wins.
Applying multiple class attributes to a HTML element is done with a space between them like this:
<code>class="class1 class2"</code>
Note: It doesn't matter which order the classes are listed in the HTML element.
However, the order of the <code>class</code> declarations in the <code>&#60;style&#62;</code> section are what is important. The second declaration will always take precedence over the first. Because <code>.blue-text</code> is declared second, it overrides the attributes of <code>.pink-text</code>
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Your <code>h1</code> element should have the class <code>pink-text</code>.
testString: 'assert($("h1").hasClass("pink-text"), ''Your <code>h1</code> element should have the class <code>pink-text</code>.'');'
- text: Your <code>h1</code> element should have the class <code>blue-text</code>.
testString: 'assert($("h1").hasClass("blue-text"), ''Your <code>h1</code> element should have the class <code>blue-text</code>.'');'
- text: Both <code>blue-text</code> and <code>pink-text</code> should belong to the same <code>h1</code> element.
testString: 'assert($(".pink-text").hasClass("blue-text"), ''Both <code>blue-text</code> and <code>pink-text</code> should belong to the same <code>h1</code> element.'');'
- text: Your <code>h1</code> element should be blue.
testString: 'assert($("h1").css("color") === "rgb(0, 0, 255)", ''Your <code>h1</code> element should be blue.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```html
<style>
body {
background-color: black;
font-family: monospace;
color: green;
}
.pink-text {
color: pink;
}
</style>
<h1 class="pink-text">Hello World!</h1>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,65 @@
---
id: bad87fee1348bd9aedf08756
title: Prioritize One Style Over Another
challengeType: 0
videoUrl: 'https://scrimba.com/c/cZ8wnHv'
---
## Description
<section id='description'>
Sometimes your HTML elements will receive multiple styles that conflict with one another.
For example, your <code>h1</code> element can't be both green and pink at the same time.
Let's see what happens when we create a class that makes text pink, then apply it to an element. Will our class <em>override</em> the <code>body</code> element's <code>color: green;</code> CSS property?
</section>
## Instructions
<section id='instructions'>
Create a CSS class called <code>pink-text</code> that gives an element the color pink.
Give your <code>h1</code> element the class of <code>pink-text</code>.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Your <code>h1</code> element should have the class <code>pink-text</code>.
testString: 'assert($("h1").hasClass("pink-text"), ''Your <code>h1</code> element should have the class <code>pink-text</code>.'');'
- text: 'Your <code>&#60;style&#62;</code> should have a <code>pink-text</code> CSS class that changes the <code>color</code>.'
testString: 'assert(code.match(/\.pink-text\s*\{\s*color\s*:\s*.+\s*;\s*\}/g), ''Your <code>&#60;style&#62;</code> should have a <code>pink-text</code> CSS class that changes the <code>color</code>.'');'
- text: Your <code>h1</code> element should be pink.
testString: 'assert($("h1").css("color") === "rgb(255, 192, 203)", ''Your <code>h1</code> element should be pink.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```html
<style>
body {
background-color: black;
font-family: monospace;
color: green;
}
</style>
<h1>Hello World!</h1>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,93 @@
---
id: bad87fee1348bd9aede08807
title: Set the Font Family of an Element
challengeType: 0
videoUrl: 'https://scrimba.com/c/c3bvpCg'
---
## Description
<section id='description'>
You can set which font an element should use, by using the <code>font-family</code> property.
For example, if you wanted to set your <code>h2</code> element's font to <code>sans-serif</code>, you would use the following CSS:
<blockquote>h2 {<br>&nbsp;&nbsp;font-family: sans-serif;<br>}</blockquote>
</section>
## Instructions
<section id='instructions'>
Make all of your <code>p</code> elements use the <code>monospace</code> font.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Your <code>p</code> elements should use the font <code>monospace</code>.
testString: 'assert($("p").not(".red-text").css("font-family").match(/monospace/i), ''Your <code>p</code> elements should use the font <code>monospace</code>.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```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://bit.ly/fcc-relaxing-cat" 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="/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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,116 @@
---
id: bad87eee1348bd9aede07836
title: Set the id of an Element
challengeType: 0
videoUrl: 'https://scrimba.com/c/cN6MEc2'
---
## Description
<section id='description'>
In addition to classes, each HTML element can also have an <code>id</code> attribute.
There are several benefits to using <code>id</code> attributes: You can use an <code>id</code> to style a single element and later you'll learn that you can use them to select and modify specific elements with JavaScript.
<code>id</code> attributes should be unique. Browsers won't enforce this, but it is a widely agreed upon best practice. So please don't give more than one element the same <code>id</code> attribute.
Here's an example of how you give your <code>h2</code> element the id of <code>cat-photo-app</code>:
<code>&#60;h2 id="cat-photo-app"></code>
</section>
## Instructions
<section id='instructions'>
Give your <code>form</code> element the id <code>cat-photo-form</code>.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Give your <code>form</code> element the id of <code>cat-photo-form</code>.
testString: 'assert($("form").attr("id") === "cat-photo-form", ''Give your <code>form</code> element the id of <code>cat-photo-form</code>.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```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://bit.ly/fcc-relaxing-cat" 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="/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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,102 @@
---
id: bad87fee1348bd9acdf08812
title: Size Your Images
challengeType: 0
videoUrl: 'https://scrimba.com/c/cM9MmCP'
---
## Description
<section id='description'>
CSS has a property called <code>width</code> that controls an element's width. Just like with fonts, we'll use <code>px</code> (pixels) to specify the image's width.
For example, if we wanted to create a CSS class called <code>larger-image</code> that gave HTML elements a width of 500 pixels, we'd use:
<blockquote>&#60;style&#62;<br>&nbsp;&nbsp;.larger-image {<br>&nbsp;&nbsp;&nbsp;&nbsp;width: 500px;<br>&nbsp;&nbsp;}<br>&#60;/style&#62;</blockquote>
</section>
## Instructions
<section id='instructions'>
Create a class called <code>smaller-image</code> and use it to resize the image so that it's only 100 pixels wide.
<strong>Note</strong><br>Due to browser implementation differences, you may need to be at 100% zoom to pass the tests on this challenge.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Your <code>img</code> element should have the class <code>smaller-image</code>.
testString: 'assert($("img[src=''https://bit.ly/fcc-relaxing-cat'']").attr(''class'') === "smaller-image", ''Your <code>img</code> element should have the class <code>smaller-image</code>.'');'
- text: Your image should be 100 pixels wide. Browser zoom should be at 100%.
testString: 'assert($("img").width() === 100, ''Your image should be 100 pixels wide. Browser zoom should be at 100%.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```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://bit.ly/fcc-relaxing-cat" 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="/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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,109 @@
---
id: bad87fee1348bd9aedf08808
title: Specify How Fonts Should Degrade
challengeType: 0
videoUrl: 'https://scrimba.com/c/cpVKBfQ'
---
## Description
<section id='description'>
There are several default fonts that are available in all browsers. These generic font families include <code>monospace</code>, <code>serif</code> and <code>sans-serif</code>
When one font isn't available, you can tell the browser to "degrade" to another font.
For example, if you wanted an element to use the <code>Helvetica</code> font, but degrade to the <code>sans-serif</code> font when <code>Helvetica</code> wasn't available, you will specify it as follows:
<blockquote>p {<br>&nbsp;&nbsp;font-family: Helvetica, sans-serif;<br>}</blockquote>
Generic font family names are not case-sensitive. Also, they do not need quotes because they are CSS keywords.
</section>
## Instructions
<section id='instructions'>
To begin with, apply the <code>monospace</code> font to the <code>h2</code> element, so that it now has two fonts - <code>Lobster</code> and <code>monospace</code>.
In the last challenge, you imported the <code>Lobster</code> font using the <code>link</code> tag. Now comment out that import of the <code>Lobster</code> font(using the HTML comments you learned before) from Google Fonts so that it isn't available anymore. Notice how your <code>h2</code> element degrades to the <code>monospace</code> font.
<strong>Note</strong><br>If you have the Lobster font installed on your computer, you won't see the degradation because your browser is able to find the font.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Your h2 element should use the font <code>Lobster</code>.
testString: 'assert($("h2").css("font-family").match(/^"?lobster/i), ''Your h2 element should use the font <code>Lobster</code>.'');'
- text: Your h2 element should degrade to the font <code>monospace</code> when <code>Lobster</code> is not available.
testString: 'assert(/\s*h2\s*\{\s*font-family\:\s*(\''|")?Lobster(\''|")?,\s*monospace\s*;\s*\}/gi.test(code), ''Your h2 element should degrade to the font <code>monospace</code> when <code>Lobster</code> is not available.'');'
- text: 'Comment out your call to Google for the <code>Lobster</code> font by putting <code>&#60!--</code> in front of it.'
testString: 'assert(new RegExp("<!--[^fc]", "gi").test(code), ''Comment out your call to Google for the <code>Lobster</code> font by putting <code>&#60!--</code> in front of it.'');'
- text: 'Be sure to close your comment by adding <code>--&#62;</code>.'
testString: 'assert(new RegExp("[^fc]-->", "gi").test(code), ''Be sure to close your comment by adding <code>--&#62;</code>.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```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://bit.ly/fcc-relaxing-cat" 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="/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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,95 @@
---
id: bad87fee1348bd9aefe08806
title: Style Multiple Elements with a CSS Class
challengeType: 0
videoUrl: 'https://scrimba.com/c/cRkVbsQ'
---
## Description
<section id='description'>
Classes allow you to use the same CSS styles on multiple HTML elements. You can see this by applying your <code>red-text</code> class to the first <code>p</code> element.
</section>
## Instructions
<section id='instructions'>
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Your <code>h2</code> element should be red.
testString: 'assert($("h2").css("color") === "rgb(255, 0, 0)", ''Your <code>h2</code> element should be red.'');'
- text: Your <code>h2</code> element should have the class <code>red-text</code>.
testString: 'assert($("h2").hasClass("red-text"), ''Your <code>h2</code> element should have the class <code>red-text</code>.'');'
- text: Your first <code>p</code> element should be red.
testString: 'assert($("p:eq(0)").css("color") === "rgb(255, 0, 0)", ''Your first <code>p</code> element should be red.'');'
- text: Your second and third <code>p</code> elements should not be red.
testString: 'assert(!($("p:eq(1)").css("color") === "rgb(255, 0, 0)") && !($("p:eq(2)").css("color") === "rgb(255, 0, 0)"), ''Your second and third <code>p</code> elements should not be red.'');'
- text: Your first <code>p</code> element should have the class <code>red-text</code>.
testString: 'assert($("p:eq(0)").hasClass("red-text"), ''Your first <code>p</code> element should have the class <code>red-text</code>.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```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://bit.ly/fcc-relaxing-cat" 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="/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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,60 @@
---
id: bad87fee1348bd9aedf08736
title: Style the HTML Body Element
challengeType: 0
videoUrl: 'https://scrimba.com/c/cB77PHW'
---
## Description
<section id='description'>
Now let's start fresh and talk about CSS inheritance.
Every HTML page has a <code>body</code> element.
</section>
## Instructions
<section id='instructions'>
We can prove that the <code>body</code> element exists here by giving it a <code>background-color</code> of black.
We can do this by adding the following to our <code>style</code> element:
<blockquote>body {<br>&nbsp;&nbsp;background-color: black;<br>}</blockquote>
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Give your <code>body</code> element the <code>background-color</code> of black.
testString: 'assert($("body").css("background-color") === "rgb(0, 0, 0)", ''Give your <code>body</code> element the <code>background-color</code> of black.'');'
- text: Make sure your CSS rule is properly formatted with both opening and closing curly brackets.
testString: 'assert(code.match(/<style>\s*body\s*\{\s*background.*\s*:\s*.*;\s*\}\s*<\/style>/i), ''Make sure your CSS rule is properly formatted with both opening and closing curly brackets.'');'
- text: Make sure your CSS rule ends with a semi-colon.
testString: 'assert(code.match(/<style>\s*body\s*\{\s*background.*\s*:\s*.*;\s*\}\s*<\/style>/i), ''Make sure your CSS rule ends with a semi-colon.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```html
<style>
</style>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,90 @@
---
id: bad82fee1322bd9aedf08721
title: Understand Absolute versus Relative Units
challengeType: 0
videoUrl: 'https://scrimba.com/c/cN66JSL'
---
## Description
<section id='description'>
The last several challenges all set an element's margin or padding with pixels (<code>px</code>). Pixels are a type of length unit, which is what tells the browser how to size or space an item. In addition to <code>px</code>, CSS has a number of different length unit options that you can use.
The two main types of length units are absolute and relative. Absolute units tie to physical units of length. For example, <code>in</code> and <code>mm</code> refer to inches and millimeters, respectively. Absolute length units approximate the actual measurement on a screen, but there are some differences depending on a screen's resolution.
Relative units, such as <code>em</code> or <code>rem</code>, are relative to another length value. For example, <code>em</code> is based on the size of an element's font. If you use it to set the <code>font-size</code> property itself, it's relative to the parent's <code>font-size</code>.
<strong>Note</strong><br>There are several relative unit options that are tied to the size of the viewport. They are covered in the Responsive Web Design Principles section.
</section>
## Instructions
<section id='instructions'>
Add a <code>padding</code> property to the element with class <code>red-box</code> and set it to <code>1.5em</code>.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Your <code>red-box</code> class should have a <code>padding</code> property.
testString: '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'', ''Your <code>red-box</code> class should have a <code>padding</code> property.'');'
- text: Your <code>red-box</code> class should give elements 1.5em of <code>padding</code>.
testString: 'assert(code.match(/\.red-box\s*?{\s*?.*?\s*?.*?\s*?padding:\s*?1\.5em/gi), ''Your <code>red-box</code> class should give elements 1.5em of <code>padding</code>.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,100 @@
---
id: bad87fee1348bd9aecf08806
title: Use a CSS Class to Style an Element
challengeType: 0
videoUrl: 'https://scrimba.com/c/c2MvDtV'
---
## Description
<section id='description'>
Classes are reusable styles that can be added to HTML elements.
Here's an example CSS class declaration:
<blockquote>&#60;style&#62;<br>&nbsp;&nbsp;.blue-text {<br>&nbsp;&nbsp;&nbsp;&nbsp;color: blue;<br>&nbsp;&nbsp;}<br>&#60;/style&#62;</blockquote>
You can see that we've created a CSS class called <code>blue-text</code> within the <code>&#60;style&#62;</code> tag.
You can apply a class to an HTML element like this:
<code>&#60;h2 class="blue-text"&#62;CatPhotoApp&#60;/h2&#62;</code>
Note that in your CSS <code>style</code> element, class names start with a period. In your HTML elements' class attribute, the class name does not include the period.
</section>
## Instructions
<section id='instructions'>
Inside your <code>style</code> element, change the <code>h2</code> selector to <code>.red-text</code> and update the color's value from <code>blue</code> to <code>red</code>.
Give your <code>h2</code> element the <code>class</code> attribute with a value of <code>'red-text'</code>.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Your <code>h2</code> element should be red.
testString: 'assert($("h2").css("color") === "rgb(255, 0, 0)", ''Your <code>h2</code> element should be red.'');'
- text: Your <code>h2</code> element should have the class <code>red-text</code>.
testString: 'assert($("h2").hasClass("red-text"), ''Your <code>h2</code> element should have the class <code>red-text</code>.'');'
- text: Your stylesheet should declare a <code>red-text</code> class and have its color set to red.
testString: 'assert(code.match(/\.red-text\s*\{\s*color\s*:\s*red;\s*\}/g), ''Your stylesheet should declare a <code>red-text</code> class and have its color set to red.'');'
- text: 'Do not use inline style declarations like <code>style="color&#58; red"</code> in your <code>h2</code> element.'
testString: 'assert($("h2").attr("style") === undefined, ''Do not use inline style declarations like <code>style="color&#58; red"</code> in your <code>h2</code> element.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```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://bit.ly/fcc-relaxing-cat" 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="/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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,271 @@
---
id: 5a9d727a424fe3d0e10cad12
title: Use a custom CSS Variable
challengeType: 0
videoUrl: 'https://scrimba.com/c/cM989ck'
---
## Description
<section id='description'>
After you create your variable, you can assign its value to other CSS properties by referencing the name you gave it.
<blockquote>background: var(--penguin-skin);</blockquote>
This will change the background of whatever element you are targeting to gray because that is the value of the <code>--penguin-skin</code> variable.
Note that styles will not be applied unless the variable names are an exact match.
</section>
## Instructions
<section id='instructions'>
Apply the <code>--penguin-skin</code> variable to the <code>background</code> property of the <code>penguin-top</code>, <code>penguin-bottom</code>, <code>right-hand</code> and <code>left-hand</code> classes.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Apply the <code>--penguin-skin</code> variable to the <code>background</code> property of the <code>penguin-top</code> class.
testString: '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), ''Apply the <code>--penguin-skin</code> variable to the <code>background</code> property of the <code>penguin-top</code> class.'');'
- text: Apply the <code>--penguin-skin</code> variable to the <code>background</code> property of the <code>penguin-bottom</code> class.
testString: '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), ''Apply the <code>--penguin-skin</code> variable to the <code>background</code> property of the <code>penguin-bottom</code> class.'');'
- text: Apply the <code>--penguin-skin</code> variable to the <code>background</code> property of the <code>right-hand</code> class.
testString: '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), ''Apply the <code>--penguin-skin</code> variable to the <code>background</code> property of the <code>right-hand</code> class.'');'
- text: Apply the <code>--penguin-skin</code> variable to the <code>background</code> property of the <code>left-hand</code> class.
testString: 'assert(code.match(/.left-hand\s*?{[\s\S]*background\s*?:\s*?var\s*?\(\s*?--penguin-skin\s*?\)\s*?;[\s\S]*}/gi), ''Apply the <code>--penguin-skin</code> variable to the <code>background</code> property of the <code>left-hand</code> class.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```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 */
background: black;
/* change code above */
width: 50%;
height: 45%;
border-radius: 70% 70% 60% 60%;
}
.penguin-bottom {
top: 40%;
left: 23.5%;
/* change code below */
background: black;
/* change code above */
width: 53%;
height: 45%;
border-radius: 70% 70% 100% 100%;
}
.right-hand {
top: 0%;
left: -5%;
/* change code below */
background: black;
/* change code above */
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 */
background: black;
/* change code above */
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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
var code = ".penguin-top {background: var(--penguin-skin);} .penguin-bottom {background: var(--penguin-skin);} .right-hand {background: var(--penguin-skin);} .left-hand {background: var(--penguin-skin);}"
```
</section>

View File

@ -0,0 +1,285 @@
---
id: 5a9d72ad424fe3d0e10cad16
title: Use a media query to change a variable
challengeType: 0
videoUrl: 'https://scrimba.com/c/cWmL8UP'
---
## Description
<section id='description'>
CSS Variables can simplify the way you use media queries.
For instance, when your screen is smaller or larger than your media query break point, you can change the value of a variable, and it will apply its style wherever it is used.
</section>
## Instructions
<section id='instructions'>
In the <code>:root</code> selector of the <code>media query</code>, change it so <code>--penguin-size</code> is redefined and given a value of <code>200px</code>. Also, redefine <code>--penguin-skin</code> and give it a value of <code>black</code>. Then resize the preview to see this change in action.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: '<code>:root</code> should reassign the <code>--penguin-size</code> variable to <code>200px</code>.'
testString: '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), ''<code>:root</code> should reassign the <code>--penguin-size</code> variable to <code>200px</code>.'');'
- text: '<code>:root</code> should reassign the <code>--penguin-skin</code> variable to <code>black</code>.'
testString: '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), ''<code>:root</code> should reassign the <code>--penguin-skin</code> variable to <code>black</code>.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```html
<style>
:root {
--penguin-size: 300px;
--penguin-skin: gray;
--penguin-belly: white;
--penguin-beak: orange;
}
@media (max-width: 350px) {
:root {
/* add code below */
/* add code above */
}
}
.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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
var code = "@media (max-width: 350px) {:root {--penguin-size: 200px; --penguin-skin: black;}}"
```
</section>

View File

@ -0,0 +1,89 @@
---
id: bad87fee1348bd9aedf08719
title: Use Abbreviated Hex Code
challengeType: 0
videoUrl: 'https://scrimba.com/c/cRkpKAm'
---
## Description
<section id='description'>
Many people feel overwhelmed by the possibilities of more than 16 million colors. And it's difficult to remember hex code. Fortunately, you can shorten it.
For example, red's hex code <code>#FF0000</code> can be shortened to <code>#F00</code>. This shortened form gives one digit for red, one digit for green, and one digit for blue.
This reduces the total number of possible colors to around 4,000. But browsers will interpret <code>#FF0000</code> and <code>#F00</code> as exactly the same color.
</section>
## Instructions
<section id='instructions'>
Go ahead, try using the abbreviated hex codes to color the correct elements.
<table class='table table-striped'><tr><th>Color</th><th>Short Hex Code</th></tr><tr><td>Cyan</td><td><code>#0FF</code></td></tr><tr><td>Green</td><td><code>#0F0</code></td></tr><tr><td>Red</td><td><code>#F00</code></td></tr><tr><td>Fuchsia</td><td><code>#F0F</code></td></tr></table>
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Give your <code>h1</code> element with the text <code>I am red!</code> the <code>color</code> red.
testString: 'assert($(''.red-text'').css(''color'') === ''rgb(255, 0, 0)'', ''Give your <code>h1</code> element with the text <code>I am red!</code> the <code>color</code> red.'');'
- text: 'Use the abbreviate <code>hex code</code> for the color red instead of the hex code <code>#FF0000</code>.'
testString: 'assert(code.match(/\.red-text\s*?{\s*?color:\s*?#F00\s*?;\s*?}/gi), ''Use the abbreviate <code>hex code</code> for the color red instead of the hex code <code>#FF0000</code>.'');'
- text: Give your <code>h1</code> element with the text <code>I am green!</code> the <code>color</code> green.
testString: 'assert($(''.green-text'').css(''color'') === ''rgb(0, 255, 0)'', ''Give your <code>h1</code> element with the text <code>I am green!</code> the <code>color</code> green.'');'
- text: 'Use the abbreviated <code>hex code</code> for the color green instead of the hex code <code>#00FF00</code>.'
testString: 'assert(code.match(/\.green-text\s*?{\s*?color:\s*?#0F0\s*?;\s*?}/gi), ''Use the abbreviated <code>hex code</code> for the color green instead of the hex code <code>#00FF00</code>.'');'
- text: Give your <code>h1</code> element with the text <code>I am cyan!</code> the <code>color</code> cyan.
testString: 'assert($(''.cyan-text'').css(''color'') === ''rgb(0, 255, 255)'', ''Give your <code>h1</code> element with the text <code>I am cyan!</code> the <code>color</code> cyan.'');'
- text: 'Use the abbreviated <code>hex code</code> for the color cyan instead of the hex code <code>#00FFFF</code>.'
testString: 'assert(code.match(/\.cyan-text\s*?{\s*?color:\s*?#0FF\s*?;\s*?}/gi), ''Use the abbreviated <code>hex code</code> for the color cyan instead of the hex code <code>#00FFFF</code>.'');'
- text: Give your <code>h1</code> element with the text <code>I am fuchsia!</code> the <code>color</code> fuchsia.
testString: 'assert($(''.fuchsia-text'').css(''color'') === ''rgb(255, 0, 255)'', ''Give your <code>h1</code> element with the text <code>I am fuchsia!</code> the <code>color</code> fuchsia.'');'
- text: 'Use the abbreviated <code>hex code</code> for the color fuchsia instead of the hex code <code>#FF00FF</code>.'
testString: 'assert(code.match(/\.fuchsia-text\s*?{\s*?color:\s*?#F0F\s*?;\s*?}/gi), ''Use the abbreviated <code>hex code</code> for the color fuchsia instead of the hex code <code>#FF00FF</code>.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,122 @@
---
id: bad87dee1348bd9aede07836
title: Use an id Attribute to Style an Element
challengeType: 0
videoUrl: 'https://scrimba.com/c/cakyZfL'
---
## Description
<section id='description'>
One cool thing about <code>id</code> attributes is that, like classes, you can style them using CSS.
However, an <code>id</code> is not reusable and should only be applied to one element. An <code>id</code> also has a higher specificity (importance) than a class so if both are applied to the same element and have conflicting styles, the styles of the <code>id</code> will be applied.
Here's an example of how you can take your element with the <code>id</code> attribute of <code>cat-photo-element</code> and give it the background color of green. In your <code>style</code> element:
<blockquote>#cat-photo-element {<br>&nbsp;&nbsp;background-color: green;<br>}</blockquote>
Note that inside your <code>style</code> element, you always reference classes by putting a <code>.</code> in front of their names. You always reference ids by putting a <code>#</code> in front of their names.
</section>
## Instructions
<section id='instructions'>
Try giving your form, which now has the <code>id</code> attribute of <code>cat-photo-form</code>, a green background.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Give your <code>form</code> element the id of <code>cat-photo-form</code>.
testString: 'assert($("form").attr("id") === "cat-photo-form", ''Give your <code>form</code> element the id of <code>cat-photo-form</code>.'');'
- text: Your <code>form</code> element should have the <code>background-color</code> of green.
testString: 'assert($("#cat-photo-form").css("background-color") === "rgb(0, 128, 0)", ''Your <code>form</code> element should have the <code>background-color</code> of green.'');'
- text: Make sure your <code>form</code> element has an <code>id</code> attribute.
testString: 'assert(code.match(/<form.*cat-photo-form.*>/gi) && code.match(/<form.*cat-photo-form.*>/gi).length > 0, ''Make sure your <code>form</code> element has an <code>id</code> attribute.'');'
- text: Do not give your <code>form</code> any <code>class</code> or <code>style</code> attributes.
testString: 'assert(!code.match(/<form.*style.*>/gi) && !code.match(/<form.*class.*>/gi), ''Do not give your <code>form</code> any <code>class</code> or <code>style</code> attributes.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```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://bit.ly/fcc-relaxing-cat" 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="/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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,119 @@
---
id: 58c383d33e2e3259241f3076
title: Use Attribute Selectors to Style Elements
challengeType: 0
videoUrl: 'https://scrimba.com/c/cnpymfJ'
---
## Description
<section id='description'>
You have been giving <code>id</code> or <code>class</code> attributes to elements that you wish to specifically style. These are known as ID and class selectors. There are other CSS Selectors you can use to select custom groups of elements to style.
Let's bring out CatPhotoApp again to practice using CSS Selectors.
For this challenge, you will use the <code>[attr=value]</code> attribute selector to style the checkboxes in CatPhotoApp. This selector matches and styles elements with a specific attribute value. For example, the below code changes the margins of all elements with the attribute <code>type</code> and a corresponding value of <code>radio</code>:
<blockquote>[type='radio'] {<br>&nbsp;&nbsp;margin: 20px 0px 20px 0px;<br>}</blockquote>
</section>
## Instructions
<section id='instructions'>
Using the <code>type</code> attribute selector, try to give the checkboxes in CatPhotoApp a top margin of 10px and a bottom margin of 15px.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: The <code>type</code> attribute selector should be used to select the checkboxes.
testString: 'assert(code.match(/<style>[\s\S]*?\[type=("|'')checkbox\1\]\s*?{[\s\S]*?}[\s\S]*?<\/style>/gi),''The <code>type</code> attribute selector should be used to select the checkboxes.'');'
- text: The top margins of the checkboxes should be 10px.
testString: 'assert((function() {var count=0; $("[type=''checkbox'']").each(function() { if($(this).css(''marginTop'') === ''10px'') {count++;}});return (count===3)}()),''The top margins of the checkboxes should be 10px.'');'
- text: The bottom margins of the checkboxes should be 15px.
testString: 'assert((function() {var count=0; $("[type=''checkbox'']").each(function() { if($(this).css(''marginBottom'') === ''15px'') {count++;}});return (count===3)}()),''The bottom margins of the checkboxes should be 15px.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```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://bit.ly/fcc-relaxing-cat" 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="/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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,94 @@
---
id: bad87fee1348bd9afdf08726
title: Use Clockwise Notation to Specify the Margin of an Element
challengeType: 0
videoUrl: 'https://scrimba.com/c/cB7mBS9'
---
## Description
<section id='description'>
Let's try this again, but with <code>margin</code> this time.
Instead of specifying an element's <code>margin-top</code>, <code>margin-right</code>, <code>margin-bottom</code>, and <code>margin-left</code> properties individually, you can specify them all in one line, like this:
<code>margin: 10px 20px 10px 20px;</code>
These four values work like a clock: top, right, bottom, left, and will produce the exact same result as using the side-specific margin instructions.
</section>
## Instructions
<section id='instructions'>
Use <code>Clockwise Notation</code> to give the element with the <code>blue-box</code> class a margin of <code>40px</code> on its top and left side, but only <code>20px</code> on its bottom and right side.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Your <code>blue-box</code> class should give the top of elements <code>40px</code> of <code>margin</code>.
testString: 'assert($(".blue-box").css("margin-top") === "40px", ''Your <code>blue-box</code> class should give the top of elements <code>40px</code> of <code>margin</code>.'');'
- text: Your <code>blue-box</code> class should give the right of elements <code>20px</code> of <code>margin</code>.
testString: 'assert($(".blue-box").css("margin-right") === "20px", ''Your <code>blue-box</code> class should give the right of elements <code>20px</code> of <code>margin</code>.'');'
- text: Your <code>blue-box</code> class should give the bottom of elements <code>20px</code> of <code>margin</code>.
testString: 'assert($(".blue-box").css("margin-bottom") === "20px", ''Your <code>blue-box</code> class should give the bottom of elements <code>20px</code> of <code>margin</code>.'');'
- text: Your <code>blue-box</code> class should give the left of elements <code>40px</code> of <code>margin</code>.
testString: 'assert($(".blue-box").css("margin-left") === "40px", ''Your <code>blue-box</code> class should give the left of elements <code>40px</code> of <code>margin</code>.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,95 @@
---
id: bad87fee1348bd9aedf08826
title: Use Clockwise Notation to Specify the Padding of an Element
challengeType: 0
videoUrl: 'https://scrimba.com/c/cB7mBS9'
---
## Description
<section id='description'>
Instead of specifying an element's <code>padding-top</code>, <code>padding-right</code>, <code>padding-bottom</code>, and <code>padding-left</code> properties individually, you can specify them all in one line, like this:
<code>padding: 10px 20px 10px 20px;</code>
These four values work like a clock: top, right, bottom, left, and will produce the exact same result as using the side-specific padding instructions.
</section>
## Instructions
<section id='instructions'>
Use Clockwise Notation to give the ".blue-box" class a <code>padding</code> of <code>40px</code> on its top and left side, but only <code>20px</code> on its bottom and right side.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Your <code>blue-box</code> class should give the top of elements <code>40px</code> of <code>padding</code>.
testString: 'assert($(".blue-box").css("padding-top") === "40px", ''Your <code>blue-box</code> class should give the top of elements <code>40px</code> of <code>padding</code>.'');'
- text: Your <code>blue-box</code> class should give the right of elements <code>20px</code> of <code>padding</code>.
testString: 'assert($(".blue-box").css("padding-right") === "20px", ''Your <code>blue-box</code> class should give the right of elements <code>20px</code> of <code>padding</code>.'');'
- text: Your <code>blue-box</code> class should give the bottom of elements <code>20px</code> of <code>padding</code>.
testString: 'assert($(".blue-box").css("padding-bottom") === "20px", ''Your <code>blue-box</code> class should give the bottom of elements <code>20px</code> of <code>padding</code>.'');'
- text: Your <code>blue-box</code> class should give the left of elements <code>40px</code> of <code>padding</code>.
testString: 'assert($(".blue-box").css("padding-left") === "40px", ''Your <code>blue-box</code> class should give the left of elements <code>40px</code> of <code>padding</code>.'');'
- text: You should use the clockwise notation to set the padding of <code>blue-box</code> class.
testString: 'assert(!/padding-top|padding-right|padding-bottom|padding-left/.test(code), ''You should use the clockwise notation to set the padding of <code>blue-box</code> class.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,96 @@
---
id: bad87fee1348bd9aedf08805
title: Use CSS Selectors to Style Elements
challengeType: 0
videoUrl: 'https://scrimba.com/c/cJKMBT2'
---
## Description
<section id='description'>
With CSS, there are hundreds of CSS <code>properties</code> that you can use to change the way an element looks on your page.
When you entered <code>&#60;h2 style="color: red"&#62;CatPhotoApp&#60;/h2&#62;</code>, you were styling that individual <code>h2</code> element with <code>inline CSS</code>, which stands for <code>Cascading Style Sheets</code>.
That's one way to specify the style of an element, but there's a better way to apply <code>CSS</code>.
At the top of your code, create a <code>style</code> block like this:
<blockquote>&#60;style&#62;<br>&#60;/style&#62;</blockquote>
Inside that style block, you can create a <code>CSS selector</code> for all <code>h2</code> elements. For example, if you wanted all <code>h2</code> elements to be red, you would add a style rule that looks like this:
<blockquote>&#60;style&#62;<br>&nbsp;&nbsp;h2 {color: red;}<br>&#60;/style&#62;</blockquote>
Note that it's important to have both opening and closing curly braces (<code>{</code> and <code>}</code>) around each element's style rule(s). You also need to make sure that your element's style definition is between the opening and closing style tags. Finally, be sure to add a semicolon to the end of each of your element's style rules.
</section>
## Instructions
<section id='instructions'>
Delete your <code>h2</code> element's style attribute, and instead create a CSS <code>style</code> block. Add the necessary CSS to turn all <code>h2</code> elements blue.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Remove the style attribute from your <code>h2</code> element.
testString: 'assert(!$("h2").attr("style"), ''Remove the style attribute from your <code>h2</code> element.'');'
- text: Create a <code>style</code> element.
testString: 'assert($("style") && $("style").length > 1, ''Create a <code>style</code> element.'');'
- text: Your <code>h2</code> element should be blue.
testString: 'assert($("h2").css("color") === "rgb(0, 0, 255)", ''Your <code>h2</code> element should be blue.'');'
- text: Ensure that your stylesheet <code>h2</code> declaration is valid with a semicolon and closing brace.
testString: 'assert(code.match(/h2\s*\{\s*color\s*:.*;\s*\}/g), ''Ensure that your stylesheet <code>h2</code> declaration is valid with a semicolon and closing brace.'');'
- text: Make sure all your <code>style</code> elements are valid and have a closing tag.
testString: 'assert(code.match(/<\/style>/g) && code.match(/<\/style>/g).length === (code.match(/<style((\s)*((type|media|scoped|title|disabled)="[^"]*")?(\s)*)*>/g) || []).length, ''Make sure all your <code>style</code> elements are valid and have a closing tag.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```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://bit.ly/fcc-relaxing-cat" 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="/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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,257 @@
---
id: 5a9d725e424fe3d0e10cad10
title: Use CSS Variables to change several elements at once
challengeType: 0
videoUrl: 'https://scrimba.com/c/c6bDECm'
---
## Description
<section id='description'>
<dfn>CSS Variables</dfn> are a powerful way to change many CSS style properties at once by changing only one value.
Follow the instructions below to see how changing just three values can change the styling of many elements.
</section>
## Instructions
<section id='instructions'>
In the <code>penguin</code> class, change the <code>black</code> value to <code>gray</code>, the <code>gray</code> value to <code>white</code>, and the <code>yellow</code> value to <code>orange</code>.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>penguin</code> class should declare the <code>--penguin-skin</code> variable and assign it to <code>gray</code>.
testString: 'assert(code.match(/.penguin\s*?{[\s\S]*--penguin-skin\s*?:\s*?gray\s*?;[\s\S]*}/gi), ''<code>penguin</code> class should declare the <code>--penguin-skin</code> variable and assign it to <code>gray</code>.'');'
- text: <code>penguin</code> class should declare the <code>--penguin-belly</code> variable and assign it to <code>white</code>.
testString: 'assert(code.match(/.penguin\s*?{[\s\S]*--penguin-belly\s*?:\s*?white\s*?;[\s\S]*}/gi), ''<code>penguin</code> class should declare the <code>--penguin-belly</code> variable and assign it to <code>white</code>.'');'
- text: <code>penguin</code> class should declare the <code>--penguin-beak</code> variable and assign it to <code>orange</code>.
testString: 'assert(code.match(/.penguin\s*?{[\s\S]*--penguin-beak\s*?:\s*?orange\s*?;[\s\S]*}/gi), ''<code>penguin</code> class should declare the <code>--penguin-beak</code> variable and assign it to <code>orange</code>.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```html
<style>
.penguin {
/* change code below */
--penguin-skin: black;
--penguin-belly: gray;
--penguin-beak: yellow;
/* change code above */
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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
var code = ".penguin {--penguin-skin: gray; --penguin-belly: white; --penguin-beak: orange;}"
```
</section>

View File

@ -0,0 +1,60 @@
---
id: bad87fee1348bd9aedf08726
title: Use Hex Code for Specific Colors
challengeType: 0
videoUrl: 'https://scrimba.com/c/c8W9mHM'
---
## Description
<section id='description'>
Did you know there are other ways to represent colors in CSS? One of these ways is called hexadecimal code, or <code>hex code</code> for short.
We usually use <code>decimals</code>, or base 10 numbers, which use the symbols 0 to 9 for each digit. <code>Hexadecimals</code> (or <code>hex</code>) are base 16 numbers. This means it uses sixteen distinct symbols. Like decimals, the symbols 0-9 represent the values zero to nine. Then A,B,C,D,E,F represent the values ten to fifteen. Altogether, 0 to F can represent a digit in <code>hexadecimal</code>, giving us 16 total possible values. You can find more information about <a target='_blank' href='https://en.wikipedia.org/wiki/Hexadecimal'>hexadecimal numbers here</a>.
In CSS, we can use 6 hexadecimal digits to represent colors, two each for the red (R), green (G), and blue (B) components. For example, <code>#000000</code> is black and is also the lowest possible value. You can find more information about the <a target='_blank' href='https://en.wikipedia.org/wiki/RGB_color_model'>RGB color system here</a>.
<blockquote>body {<br>&nbsp;&nbsp;color: #000000;<br>}</blockquote>
</section>
## Instructions
<section id='instructions'>
Replace the word <code>black</code> in our <code>body</code> element's background-color with its <code>hex code</code> representation, <code>#000000</code>.
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Give your <code>body</code> element the background-color of black.
testString: 'assert($("body").css("background-color") === "rgb(0, 0, 0)", ''Give your <code>body</code> element the background-color of black.'');'
- text: Use the <code>hex code</code> for the color black instead of the word <code>black</code>.
testString: 'assert(code.match(/body\s*{(([\s\S]*;\s*?)|\s*?)background.*\s*:\s*?#000(000)?((\s*})|(;[\s\S]*?}))/gi), ''Use the <code>hex code</code> for the color black instead of the word <code>black</code>.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```html
<style>
body {
background-color: black;
}
</style>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,91 @@
---
id: bad87fee1348bd9aedf08721
title: Use Hex Code to Mix Colors
challengeType: 0
videoUrl: 'https://scrimba.com/c/cK89PhP'
---
## Description
<section id='description'>
To review, hex codes use 6 hexadecimal digits to represent colors, two each for red (R), green (G), and blue (B) components.
From these three pure colors (red, green, and blue), we can vary the amounts of each to create over 16 million other colors!
For example, orange is pure red, mixed with some green, and no blue. In hex code, this translates to being <code>#FFA500</code>.
The digit <code>0</code> is the lowest number in hex code, and represents a complete absence of color.
The digit <code>F</code> is the highest number in hex code, and represents the maximum possible brightness.
</section>
## Instructions
<section id='instructions'>
Replace the color words in our <code>style</code> element with their correct hex codes.
<table class='table table-striped'><tr><th>Color</th><th>Hex Code</th></tr><tr><td>Dodger Blue</td><td><code>#1E90FF</code></td></tr><tr><td>Green</td><td><code>#00FF00</code></td></tr><tr><td>Orange</td><td><code>#FFA500</code></td></tr><tr><td>Red</td><td><code>#FF0000</code></td></tr></table>
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Give your <code>h1</code> element with the text <code>I am red!</code> the <code>color</code> red.
testString: 'assert($(''.red-text'').css(''color'') === ''rgb(255, 0, 0)'', ''Give your <code>h1</code> element with the text <code>I am red!</code> the <code>color</code> red.'');'
- text: Use the <code>hex code</code> for the color red instead of the word <code>red</code>.
testString: 'assert(code.match(/\.red-text\s*?{\s*?color:\s*?#FF0000\s*?;\s*?}/gi), ''Use the <code>hex code</code> for the color red instead of the word <code>red</code>.'');'
- text: Give your <code>h1</code> element with the text <code>I am green!</code> the <code>color</code> green.
testString: 'assert($(''.green-text'').css(''color'') === ''rgb(0, 255, 0)'', ''Give your <code>h1</code> element with the text <code>I am green!</code> the <code>color</code> green.'');'
- text: Use the <code>hex code</code> for the color green instead of the word <code>green</code>.
testString: 'assert(code.match(/\.green-text\s*?{\s*?color:\s*?#00FF00\s*?;\s*?}/gi), ''Use the <code>hex code</code> for the color green instead of the word <code>green</code>.'');'
- text: Give your <code>h1</code> element with the text <code>I am dodger blue!</code> the <code>color</code> dodger blue.
testString: 'assert($(''.dodger-blue-text'').css(''color'') === ''rgb(30, 144, 255)'', ''Give your <code>h1</code> element with the text <code>I am dodger blue!</code> the <code>color</code> dodger blue.'');'
- text: Use the <code>hex code</code> for the color dodger blue instead of the word <code>dodgerblue</code>.
testString: 'assert(code.match(/\.dodger-blue-text\s*?{\s*?color:\s*?#1E90FF\s*?;\s*?}/gi), ''Use the <code>hex code</code> for the color dodger blue instead of the word <code>dodgerblue</code>.'');'
- text: Give your <code>h1</code> element with the text <code>I am orange!</code> the <code>color</code> orange.
testString: 'assert($(''.orange-text'').css(''color'') === ''rgb(255, 165, 0)'', ''Give your <code>h1</code> element with the text <code>I am orange!</code> the <code>color</code> orange.'');'
- text: Use the <code>hex code</code> for the color orange instead of the word <code>orange</code>.
testString: 'assert(code.match(/\.orange-text\s*?{\s*?color:\s*?#FFA500\s*?;\s*?}/gi), ''Use the <code>hex code</code> for the color orange instead of the word <code>orange</code>.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,87 @@
---
id: bad82fee1348bd9aedf08721
title: Use RGB to Mix Colors
challengeType: 0
videoUrl: 'https://scrimba.com/c/cm24JU6'
---
## Description
<section id='description'>
Just like with hex code, you can mix colors in RGB by using combinations of different values.
</section>
## Instructions
<section id='instructions'>
Replace the hex codes in our <code>style</code> element with their correct RGB values.
<table class='table table-striped'><tr><th>Color</th><th>RGB</th></tr><tr><td>Blue</td><td><code>rgb(0, 0, 255)</code></td></tr><tr><td>Red</td><td><code>rgb(255, 0, 0)</code></td></tr><tr><td>Orchid</td><td><code>rgb(218, 112, 214)</code></td></tr><tr><td>Sienna</td><td><code>rgb(160, 82, 45)</code></td></tr></table>
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Give your <code>h1</code> element with the text <code>I am red!</code> the <code>color</code> red.
testString: 'assert($(''.red-text'').css(''color'') === ''rgb(255, 0, 0)'', ''Give your <code>h1</code> element with the text <code>I am red!</code> the <code>color</code> red.'');'
- text: Use <code>rgb</code> for the color red.
testString: 'assert(code.match(/\.red-text\s*?{\s*?color:\s*?rgb\(\s*?255\s*?,\s*?0\s*?,\s*?0\s*?\)\s*?;\s*?}/gi), ''Use <code>rgb</code> for the color red.'');'
- text: Give your <code>h1</code> element with the text <code>I am orchid!</code> the <code>color</code> orchid.
testString: 'assert($(''.orchid-text'').css(''color'') === ''rgb(218, 112, 214)'', ''Give your <code>h1</code> element with the text <code>I am orchid!</code> the <code>color</code> orchid.'');'
- text: Use <code>rgb</code> for the color orchid.
testString: 'assert(code.match(/\.orchid-text\s*?{\s*?color:\s*?rgb\(\s*?218\s*?,\s*?112\s*?,\s*?214\s*?\)\s*?;\s*?}/gi), ''Use <code>rgb</code> for the color orchid.'');'
- text: Give your <code>h1</code> element with the text <code>I am blue!</code> the <code>color</code> blue.
testString: 'assert($(''.blue-text'').css(''color'') === ''rgb(0, 0, 255)'', ''Give your <code>h1</code> element with the text <code>I am blue!</code> the <code>color</code> blue.'');'
- text: Use <code>rgb</code> for the color blue.
testString: 'assert(code.match(/\.blue-text\s*?{\s*?color:\s*?rgb\(\s*?0\s*?,\s*?0\s*?,\s*?255\s*?\)\s*?;\s*?}/gi), ''Use <code>rgb</code> for the color blue.'');'
- text: Give your <code>h1</code> element with the text <code>I am sienna!</code> the <code>color</code> sienna.
testString: 'assert($(''.sienna-text'').css(''color'') === ''rgb(160, 82, 45)'', ''Give your <code>h1</code> element with the text <code>I am sienna!</code> the <code>color</code> sienna.'');'
- text: Use <code>rgb</code> for the color sienna.
testString: 'assert(code.match(/\.sienna-text\s*?{\s*?color:\s*?rgb\(\s*?160\s*?,\s*?82\s*?,\s*?45\s*?\)\s*?;\s*?}/gi), ''Use <code>rgb</code> for the color sienna.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```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>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,65 @@
---
id: bad87fee1348bd9aede08718
title: Use RGB values to Color Elements
challengeType: 0
videoUrl: 'https://scrimba.com/c/cRkp2fr'
---
## Description
<section id='description'>
Another way you can represent colors in CSS is by using <code>RGB</code> values.
The RGB value for black looks like this:
<code>rgb(0, 0, 0)</code>
The RGB value for white looks like this:
<code>rgb(255, 255, 255)</code>
Instead of using six hexadecimal digits like you do with hex code, with <code>RGB</code> you specify the brightness of each color with a number between 0 and 255.
If you do the math, the two digits for one color equal 16 times 16, which gives us 256 total values. So <code>RGB</code>, which starts counting from zero, has the exact same number of possible values as hex code.
Here's an example of how you'd change the body background to orange using its RGB code.
<blockquote>body {<br>&nbsp;&nbsp;background-color: rgb(255, 165, 0);<br>}</blockquote>
</section>
## Instructions
<section id='instructions'>
Let's replace the hex code in our <code>body</code> element's background color with the RGB value for black: <code>rgb(0, 0, 0)</code>
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: Your <code>body</code> element should have a black background.
testString: 'assert($("body").css("background-color") === "rgb(0, 0, 0)", ''Your <code>body</code> element should have a black background.'');'
- text: Use <code>rgb</code> to give your <code>body</code> element a color of black.
testString: 'assert(code.match(/rgb\s*\(\s*0\s*,\s*0\s*,\s*0\s*\)/ig), ''Use <code>rgb</code> to give your <code>body</code> element a color of black.'');'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='html-seed'>
```html
<style>
body {
background-color: #F00;
}
</style>
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>