--- id: bad87fee1348bd9aefe08806 title: Style Multiple Elements with a CSS Class challengeType: 0 videoUrl: 'https://scrimba.com/c/cRkVbsQ' forumTopicId: 18311 localeTitle: 使用 class 选择器设置多个元素的样式 --- ## Description
通过 CSS class 选择器,多个 HTML 元素可以使用相同的 CSS 样式规则。你可以将red-textclass 选择器应用在第一个p元素上。
## Instructions
## Tests
```yml tests: - text: 'h2元素应该是红色的。' testString: assert($("h2").css("color") === "rgb(255, 0, 0)"); - text: 'h2元素应该含有red-text class 选择器。' testString: assert($("h2").hasClass("red-text")); - text: '第一个p元素应该为红色。' testString: assert($("p:eq(0)").css("color") === "rgb(255, 0, 0)"); - text: '第二和第三个p元素不应该为红色。' testString: assert(!($("p:eq(1)").css("color") === "rgb(255, 0, 0)") && !($("p:eq(2)").css("color") === "rgb(255, 0, 0)")); - text: '第一个p元素应该包含red-text class 选择器。' testString: assert($("p:eq(0)").hasClass("red-text")); ```
## Challenge Seed
```html

CatPhotoApp

点击查看更多猫图.

一只仰卧着的萌猫

猫咪最喜欢的三件东西:

  • 猫薄荷
  • 激光笔
  • 千层饼

猫咪最讨厌的三件东西:

  1. 跳蚤
  2. 打雷
  3. 同类


```
## Solution
```html // solution required ```