* feat(tools): add seed/solution restore script * chore(curriculum): remove empty sections' markers * chore(curriculum): add seed + solution to Chinese * chore: remove old formatter * fix: update getChallenges parse translated challenges separately, without reference to the source * chore(curriculum): add dashedName to English * chore(curriculum): add dashedName to Chinese * refactor: remove unused challenge property 'name' * fix: relax dashedName requirement * fix: stray tag Remove stray `pre` tag from challenge file. Signed-off-by: nhcarrigan <nhcarrigan@gmail.com> Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
2.3 KiB
2.3 KiB
id, title, challengeType, videoUrl, forumTopicId, dashedName
id | title | challengeType | videoUrl | forumTopicId | dashedName |
---|---|---|---|---|---|
bad87fee1348bd8aedf06756 | ID 选择器优先级高于 Class 选择器 | 0 | https://scrimba.com/c/cRkpDhB | 18251 | override-class-declarations-by-styling-id-attributes |
--description--
我们刚刚证明了浏览器读取 CSS 是由上到下的。这就意味着,如果发生冲突,浏览器将会应用最后声明的样式。
不过我们还没结束,还有其他方法来覆盖 CSS 样式。你还记得 id 属性吗?
通过给 h1
元素添加 id 属性,我们便可以此来覆盖 class 属性中定义的同名样式。
--instructions--
给 h1
元素添加 id 属性,属性值为 orange-text
。设置方式如下:
<h1 id="orange-text">
h1
元素应继续保留 blue-text
和 pink-text
这两个 class。
在 style
元素中创建名为 orange-text
的 id 选择器。例子如下:
#brown-text {
color: brown;
}
**注意:**无论在 pink-text
class 之前或者之后声明,id 选择器的优先级总是高于 class 选择器。
--hints--
h1
元素应包含 pink-text
class。
assert($('h1').hasClass('pink-text'));
h1
元素应包含 blue-text
class。
assert($('h1').hasClass('blue-text'));
h1
的 id 属性值应为 orange-text
。
assert($('h1').attr('id') === 'orange-text');
应只有一个 h1
元素。
assert($('h1').length === 1);
应存在名为 orange-text
的 id 选择器。
assert(code.match(/#orange-text\s*{/gi));
不要在 h1
元素里面使用行内样式。
assert(!code.match(/<h1.*style.*>/gi));
h1
元素的字体颜色应为橘色。
assert($('h1').css('color') === 'rgb(255, 165, 0)');
--seed--
--seed-contents--
<style>
body {
background-color: black;
font-family: monospace;
color: green;
}
.pink-text {
color: pink;
}
.blue-text {
color: blue;
}
</style>
<h1 class="pink-text blue-text">Hello World!</h1>
--solutions--
<style>
body {
background-color: black;
font-family: monospace;
color: green;
}
.pink-text {
color: pink;
}
.blue-text {
color: blue;
}
#orange-text {
color: orange;
}
</style>
<h1 id="orange-text" class="pink-text blue-text">Hello World!</h1>