freeCodeCamp/curriculum/challenges/chinese/01-responsive-web-design/basic-css/prioritize-one-style-over-a...

1.8 KiB
Raw Blame History

id title challengeType videoUrl localeTitle
bad87fee1348bd9aedf08756 Prioritize One Style Over Another 0 将一种风格优先于另一种风格

Description

有时您的HTML元素将收到多个彼此冲突的样式。例如您的h1元素不能同时为绿色和粉红色。让我们看看当我们创建一个使文本变为粉红色的类,然后将其应用于元素时会发生什么。我们的类会覆盖 body元素的color: green; CSS属性

Instructions

创建一个名为pink-text的CSS类它为元素提供粉红色。为你的h1元素提供pink-text类。

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>&lt;style&gt;</code>应该有一个改变<code>color</code>的<code>pink-text</code> CSS类。
    testString: 'assert(code.match(/\.pink-text\s*\{\s*color\s*:\s*.+\s*;\s*\}/g), "Your <code>&#60;style&#62;</code> should have a <code>pink-text</code> CSS class that changes the <code>color</code>.");'
  - text: 你的<code>h1</code>元素应该是粉红色的。
    testString: 'assert($("h1").css("color") === "rgb(255, 192, 203)", "Your <code>h1</code> element should be pink.");'

Challenge Seed

<style>
  body {
    background-color: black;
    font-family: monospace;
    color: green;
  }
</style>
<h1>Hello World!</h1>

Solution

// solution required