---
id: bad87fee1348bd9aedf08756
title: Prioritize One Style Over Another
challengeType: 0
videoUrl: ''
localeTitle: 将一种风格优先于另一种风格
---
## Description
有时,您的HTML元素将收到多个彼此冲突的样式。例如,您的h1
元素不能同时为绿色和粉红色。让我们看看当我们创建一个使文本变为粉红色的类,然后将其应用于元素时会发生什么。我们的类会覆盖 body
元素的color: green;
CSS属性?
## Instructions
创建一个名为pink-text
的CSS类,它为元素提供粉红色。为你的h1
元素提供pink-text
类。
## Tests
```yml
tests:
- text: 您的h1
元素应该具有pink-text
类。
testString: 'assert($("h1").hasClass("pink-text"), "Your h1
element should have the class pink-text
.");'
- text: 你的<style>
应该有一个改变color
的pink-text
CSS类。
testString: 'assert(code.match(/\.pink-text\s*\{\s*color\s*:\s*.+\s*;\s*\}/g), "Your <style>
should have a pink-text
CSS class that changes the color
.");'
- text: 你的h1
元素应该是粉红色的。
testString: 'assert($("h1").css("color") === "rgb(255, 192, 203)", "Your h1
element should be pink.");'
```
## Challenge Seed
## Solution
```js
// solution required
```