freeCodeCamp/curriculum/challenges/chinese/01-responsive-web-design/basic-css/override-styles-in-subseque...

66 lines
2.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
id: bad87fee1348bd9aedf04756
title: Override Styles in Subsequent CSS
challengeType: 0
videoUrl: ''
localeTitle: 覆盖后续CSS中的样式
---
## Description
<section id="description">我们的“粉红色文本”类覆盖了我们的<code>body</code>元素的CSS声明我们刚刚证明我们的类将覆盖<code>body</code>元素的CSS。所以下一个合乎逻辑的问题是我们可以做些什么来覆盖我们的<code>pink-text</code>类? </section>
## Instructions
<section id="instructions">创建一个名为<code>blue-text</code>的附加CSS类它为元素提供蓝色。确保它低于<code>pink-text</code>类声明。除了<code>pink-text</code>类之外,将<code>blue-text</code>类应用于<code>h1</code>元素让我们看看哪个获胜。将多个类属性应用于HTML元素是通过它们之间的空格完成的如下所示 <code>class=&quot;class1 class2&quot;</code>注意HTML元素中列出的类的顺序无关紧要。但是 <code>&lt;style&gt;</code>部分中的<code>class</code>声明的顺序是重要的。第二个声明将始终优先于第一个声明。因为<code>.blue-text</code>被声明为第二个,所以它会覆盖<code>.pink-text</code>的属性</section>
## Tests
<section id='tests'>
```yml
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>blue-text</code>和<code>pink-text</code>都应属于同一个<code>h1</code>元素。
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: 你的<code>h1</code>元素应该是蓝色的。
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>