Skip to content

Commit b773fd3

Browse files
committed
Merge branch 'master' of https://github.com/mdn/css-examples
2 parents 21a9039 + 8e71f59 commit b773fd3

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

learn/solutions.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22

33
Solutions for the tasks in the CSS Learn section of MDN.
44

5+
## The Cascade
6+
7+
[Task](https://developer.mozilla.org/en-US/docs/User:chrisdavidmills/CSS_Learn/Cascade_and_inheritance#Active_learning_playing_with_the_cascade)
8+
9+
Task: Write a declaration in a new rule that will reset the background color back to white, without using an actual color value?
10+
11+
One possible solution is as follows:
12+
13+
```
14+
#outer #inner a {
15+
background-color: initial;
16+
}
17+
```
18+
19+
There are two things you need to do in this task. First, you need to write a selector for the `a` element which is more specific than the selector used to turn the background blue. I have achieved this by using the `id` selector which has very high specificity.
20+
21+
Then you need to remember that there are special keyword values for all properties. In this case I am using `inherit` to set the background back to be the same as its parent element.
22+
523
## Attribute Selectors
624

725
[Task](https://developer.mozilla.org/en-US/docs/User:chrisdavidmills/CSS_Learn/CSS_Selectors/Attribute_selectors#Try_it_out)
@@ -36,6 +54,22 @@ a[href^="https"] {
3654
}
3755
```
3856

57+
## The Box Model
58+
59+
[Task](https://developer.mozilla.org/en-US/docs/User:chrisdavidmills/CSS_Learn/The_Box_Model#Playing_with_box_models)
60+
61+
Task: Change the size of the second box (by adding CSS to the .alternate class) to make it match the first box in width and height.
62+
63+
```
64+
.alternate {
65+
box-sizing: border-box;
66+
width: 390px;
67+
height: 240px;
68+
}
69+
```
70+
71+
You will need to increase the height and width of the second block, to add the size of the padding and border.
72+
3973
## Backgrounds and Borders
4074

4175
To style the box we add a border, using the `border` property. Round the corners with `border-radius` and then add the background image setting the size to `contain`.
@@ -56,4 +90,4 @@ h2 {
5690
background-color: rgba(0,0,0,.5);
5791
color: white;
5892
}
59-
```
93+
```

0 commit comments

Comments
 (0)