freeCodeCamp/curriculum/challenges/chinese/04-data-visualization/data-visualization-with-d3/style-d3-labels.md

32 lines
662 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
id: 587d7faa367417b2b2512bd3
title: 给 D3 标签添加样式
challengeType: 6
forumTopicId: 301492
---
# --description--
D3 可以将样式添加到组标签中。`fill` 属性为 `text` 节点设置文本颜色,`style()` 方法设置其它样式的 CSS 规则,例如 "font-family"、"font-size"。
# --instructions--
`text` 元素的 `font-size` 设置为 25px文本颜色设置为 red。
# --hints--
所有标签的 `fill` 颜色应该是 red。
```js
assert($('text').css('fill') == 'rgb(255, 0, 0)');
```
所有标签的 `font-size` 应该为 25 个像素。
```js
assert($('text').css('font-size') == '25px');
```
# --solutions--