Skip to content

Commit 73d4826

Browse files
authored
Merge pull request mdn#77 from estelle/cascade
Minor: updates specificity weights to reflect updated tutorial. Add cascade file
2 parents c313e4c + 005a46d commit 73d4826

File tree

3 files changed

+148
-33
lines changed

3 files changed

+148
-33
lines changed

learn/cascade/cascade-layers.html

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<!doctype html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<title>cascade layers demo</title>
7+
<link rel="stylesheet" href="../styles.css">
8+
<style>
9+
10+
</style>
11+
12+
<style class="editable">
13+
@layer firstLayer, secondLayer;
14+
15+
p { /* 0-0-1 */
16+
background-color: red;
17+
color: grey !important;
18+
border: 5px inset purple;
19+
margin: 15px;
20+
}
21+
p#addSpecificity { /* 1-0-1 */
22+
border-style: solid !important;
23+
}
24+
25+
@layer firstLayer {
26+
#addSpecificity { /* 1-0-0 */
27+
background-color: blue;
28+
color: white !important;
29+
border-width: 5px;
30+
border-style: dashed !important;
31+
}
32+
}
33+
34+
@layer secondLayer {
35+
p#addSpecificity { /* 1-0-1 */
36+
background-color: green;
37+
color: orange !important;
38+
border-width: 10px;
39+
border-style: dotted !important;
40+
}
41+
}
42+
43+
</style>
44+
</head>
45+
46+
<body>
47+
<section class="preview">
48+
<p id="addSpecificity">
49+
A paragraph with a border and background
50+
</p>
51+
</section>
52+
53+
<textarea class="playable playable-css" style="height: 280px;">
54+
@layer firstLayer, secondLayer;
55+
56+
p { /* 0-0-1 */
57+
background-color: red;
58+
color: grey !important;
59+
border: 5px inset purple;
60+
}
61+
p#addSpecificity { /* 1-0-1 */
62+
border-style: solid !important;
63+
}
64+
65+
@layer firstLayer {
66+
#addSpecificity { /* 1-0-0 */
67+
background-color: blue;
68+
color: white !important;
69+
border-width: 5px;
70+
border-style: dashed !important;
71+
}
72+
}
73+
74+
@layer secondLayer {
75+
p#addSpecificity { /* 1-0-1 */
76+
background-color: green;
77+
color: orange !important;
78+
border-width: 10px;
79+
border-style: dotted !important;
80+
}
81+
}
82+
</textarea>
83+
84+
<textarea class="playable playable-html" style="height: 140px;">
85+
<p id="addSpecificity">
86+
A paragraph with a border and background
87+
</p>
88+
</textarea>
89+
90+
<div class="playable-buttons">
91+
<input id="reset" type="button" value="Reset">
92+
</div>
93+
</body>
94+
<script src="../playable.js"></script>
95+
96+
</html>

learn/cascade/specificity-boxes.html

+14-14
Original file line numberDiff line numberDiff line change
@@ -10,37 +10,37 @@
1010
</style>
1111

1212
<style class="editable">
13-
/* specificity: 0101 */
13+
/* 1. specificity: 1-0-1 */
1414
#outer a {
1515
background-color: red;
1616
}
1717

18-
/* specificity: 0201 */
18+
/* 2. specificity: 2-0-1 */
1919
#outer #inner a {
2020
background-color: blue;
2121
}
2222

23-
/* specificity: 0104 */
23+
/* 3. specificity: 1-0-4 */
2424
#outer div ul li a {
2525
color: yellow;
2626
}
2727

28-
/* specificity: 0113 */
28+
/* 4. specificity: 1-1-3 */
2929
#outer div ul .nav a {
3030
color: white;
3131
}
3232

33-
/* specificity: 0024 */
33+
/* 5. specificity: 0-2-4 */
3434
div div li:nth-child(2) a:hover {
3535
border: 10px solid black;
3636
}
3737

38-
/* specificity: 0023 */
38+
/* 6. specificity: 0-2-3 */
3939
div li:nth-child(2) a:hover {
4040
border: 10px dashed black;
4141
}
4242

43-
/* specificity: 0033 */
43+
/* 7. specificity: 0-3-3 */
4444
div div .nav:nth-child(2) a:hover {
4545
border: 10px double black;
4646
}
@@ -81,37 +81,37 @@
8181

8282
<textarea class="playable playable-css" style="height: 280px;">
8383

84-
/* specificity: 0101 */
84+
/* 1. specificity: 1-0-1 */
8585
#outer a {
8686
background-color: red;
8787
}
8888

89-
/* specificity: 0201 */
89+
/* 2. specificity: 2-0-1 */
9090
#outer #inner a {
9191
background-color: blue;
9292
}
9393

94-
/* specificity: 0104 */
94+
/* 3. specificity: 1-0-4 */
9595
#outer div ul li a {
9696
color: yellow;
9797
}
9898

99-
/* specificity: 0113 */
99+
/* 4. specificity: 1-1-3 */
100100
#outer div ul .nav a {
101101
color: white;
102102
}
103103

104-
/* specificity: 0024 */
104+
/* 5. specificity: 0-2-4 */
105105
div div li:nth-child(2) a:hover {
106106
border: 10px solid black;
107107
}
108108

109-
/* specificity: 0023 */
109+
/* 6. specificity: 0-2-3 */
110110
div li:nth-child(2) a:hover {
111111
border: 10px dashed black;
112112
}
113113

114-
/* specificity: 0033 */
114+
/* 7. specificity: 0-3-3 */
115115
div div .nav:nth-child(2) a:hover {
116116
border: 10px double black;
117117
}

learn/tasks/cascade/cascade.html

+38-19
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,25 @@
1010
</style>
1111

1212
<style class="editable">
13-
#outer div ul .nav a {
14-
background-color: yellow;
15-
padding: 5px;
16-
display: inline-block;
17-
margin-bottom: 10px;
18-
}
13+
@layer yellow, purple, green;
1914

20-
div div li a {
21-
color: rebeccapurple;
15+
@layer yellow {
16+
#outer div ul .nav a {
17+
background-color: yellow;
18+
padding: 5px;
19+
display: inline-block;
20+
margin-bottom: 10px;
21+
}
22+
}
23+
@layer purple {
24+
div div li a {
25+
color: rebeccapurple;
26+
}
27+
}
28+
@layer green {
29+
a {
30+
color: lightgreen;
31+
}
2232
}
2333
</style>
2434
</head>
@@ -34,18 +44,27 @@
3444
</div>
3545
</div>
3646
</section>
47+
<textarea class="playable playable-css" style="height: 400px;">
48+
@layer yellow, purple, green;
3749

38-
<textarea class="playable playable-css" style="height: 250px;">
39-
#outer div ul .nav a {
40-
background-color: yellow;
41-
padding: 5px;
42-
display: inline-block;
43-
margin-bottom: 10px;
44-
}
45-
46-
div div li a {
47-
color: rebeccapurple;
48-
}
50+
@layer yellow {
51+
#outer div ul .nav a {
52+
background-color: yellow;
53+
padding: 5px;
54+
display: inline-block;
55+
margin-bottom: 10px;
56+
}
57+
}
58+
@layer purple {
59+
div div li a {
60+
color: rebeccapurple;
61+
}
62+
}
63+
@layer green {
64+
a {
65+
color: lightgreen;
66+
}
67+
}
4968
</textarea>
5069

5170
<textarea class="playable playable-html" style="height: 170px;">

0 commit comments

Comments
 (0)