Files
freeCodeCamp/curriculum/challenges/chinese/01-responsive-web-design/basic-css/prioritize-one-style-over-another.chinese.md
2020-02-11 15:42:42 +09:00

1.7 KiB
Raw Blame History

id, title, challengeType, videoUrl, forumTopicId, localeTitle
id title challengeType videoUrl forumTopicId localeTitle
bad87fee1348bd9aedf08756 Prioritize One Style Over Another 0 https://scrimba.com/c/cZ8wnHv 18258 样式中的优先级

Description

有时候, HTML 元素的样式会跟其他样式发生冲突。 就像,h1元素也不能同时设置greenpink两种样式。 让我们尝试创建一个字体颜色为pink的 class并应于用其中一个元素中。猜一猜它会覆盖body元素设置的color: green;CSS 属性吗?

Instructions

创建一个能将元素的字体颜色改为pink的CSS class并起名为pink-text。 给h1元素添加pink-textclass。

Tests

tests:
  - text: '<code>h1</code>元素应该含有<code>pink-text</code> class。'
    testString: assert($("h1").hasClass("pink-text"));
  - text: '<code>&#60;style&#62;</code>标签应该含有一个可以改变字体颜色的<code>pink-text</code> class。'
    testString: 'assert(code.match(/\.pink-text\s*\{\s*color\s*:\s*.+\s*;\s*\}/g));'
  - text: '<code>h1</code>元素的字体颜色应该为<code>pink粉色</code>。'
    testString: assert($("h1").css("color") === "rgb(255, 192, 203)");

Challenge Seed

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

Solution

// solution required