Files

1.4 KiB
Raw Permalink Blame History

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
bad87fee1348bd9aedf08756 樣式中的優先級 0 https://scrimba.com/c/cZ8wnHv 18258 prioritize-one-style-over-another

--description--

有時候HTML 元素的樣式會跟其他樣式發生衝突。

就像 h1 元素不能同時設置綠色和粉色兩種顏色。

讓我們嘗試創建一個字體顏色爲粉色的 class並應用於其中一個元素中。 猜一猜,它會 覆蓋 body 元素的 color: green; CSS 規則嗎?

--instructions--

創建一個能將元素的字體顏色改爲粉色的 class並命名爲 pink-text

h1 元素添加 pink-text class。

--hints--

h1 元素應含有 pink-text class。

assert($('h1').hasClass('pink-text'));

<style> 標籤應含有一個可以改變 colorpink-text class。

assert(code.match(/\.pink-text\s*\{\s*color\s*:\s*.+\s*;?\s*\}/g));

h1 元素的字體顏色應爲粉色。

assert($('h1').css('color') === 'rgb(255, 192, 203)');

--seed--

--seed-contents--

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

--solutions--

<style>
  body {
    background-color: black;
    font-family: monospace;
    color: green;
  }
  .pink-text {
    color: pink;
  }
</style>
<h1 class="pink-text">Hello World!</h1>