--- id: bad87fee1348bd9aefe08806 title: Style Multiple Elements with a CSS Class challengeType: 0 videoUrl: '' localeTitle: 使用CSS类设置多个元素的样式 --- ## Description
类允许您在多个HTML元素上使用相同的CSS样式。您可以通过将red-text类应用于第一个p元素来查看。
## Instructions
## Tests
```yml tests: - text: 你的h2元素应该是红色的。 testString: 'assert($("h2").css("color") === "rgb(255, 0, 0)", "Your h2 element should be red.");' - text: 你的h2元素应该有red-text类。 testString: 'assert($("h2").hasClass("red-text"), "Your h2 element should have the class red-text.");' - text: 你的第一个p元素应该是红色的。 testString: 'assert($("p:eq(0)").css("color") === "rgb(255, 0, 0)", "Your first p element should be red.");' - text: 你的第二和第三个p元素不应该是红色的。 testString: 'assert(!($("p:eq(1)").css("color") === "rgb(255, 0, 0)") && !($("p:eq(2)").css("color") === "rgb(255, 0, 0)"), "Your second and third p elements should not be red.");' - text: 你的第一个p元素应该有red-text类。 testString: 'assert($("p:eq(0)").hasClass("red-text"), "Your first p element should have the class red-text.");' ```
## Challenge Seed
```html

CatPhotoApp

Click here to view more cat photos.

A cute orange cat lying on its back.

Things cats love:

  • cat nip
  • laser pointers
  • lasagna

Top 3 things cats hate:

  1. flea treatment
  2. thunder
  3. other cats


```
## Solution
```js // solution required ```