3.0 KiB
3.0 KiB
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
bad87fee1348bd8aedf06756 | Override Class Declarations by Styling ID Attributes | 0 | 通过样式ID属性覆盖类声明 |
Description
pink-text
和blue-text
类,并通过给h1
元素一个id然后设置那个id样式,使你的h1
元素变成橙色。 Instructions
h1
元素提供orange-text
的id
属性。请记住,id样式如下所示: <h1 id="orange-text">
在h1
元素上保留blue-text
和pink-text
类。在style
元素中为您的orange-text
id创建一个CSS声明。这是一个示例: #brown-text {注意:无论您是在粉红色文本类之上还是之下声明此CSS都无关紧要,因为id属性始终优先。
颜色:棕色;
}
Tests
tests:
- text: 您的<code>h1</code>元素应该具有<code>pink-text</code>类。
testString: 'assert($("h1").hasClass("pink-text"), "Your <code>h1</code> element should have the class <code>pink-text</code>.");'
- text: 你的<code>h1</code>元素应该有<code>blue-text</code> 。
testString: 'assert($("h1").hasClass("blue-text"), "Your <code>h1</code> element should have the class <code>blue-text</code>.");'
- text: 为你的<code>h1</code>元素提供<code>orange-text</code>的id。
testString: 'assert($("h1").attr("id") === "orange-text", "Give your <code>h1</code> element the id of <code>orange-text</code>.");'
- text: 应该只有一个<code>h1</code>元素。
testString: 'assert(($("h1").length === 1), "There should be only one <code>h1</code> element.");'
- text: 为您的<code>orange-text</code> ID创建一个CSS声明
testString: 'assert(code.match(/#orange-text\s*{/gi), "Create a CSS declaration for your <code>orange-text</code> id");'
- text: 不要给你的<code>h1</code>任何<code>style</code>属性。
testString: 'assert(!code.match(/<h1.*style.*>/gi), "Do not give your <code>h1</code> any <code>style</code> attributes.");'
- text: 你的<code>h1</code>元素应该是橙色的。
testString: 'assert($("h1").css("color") === "rgb(255, 165, 0)", "Your <code>h1</code> element should be orange.");'
Challenge Seed
<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>
Solution
// solution required