---
id: 587d7fa7367417b2b2512bc6
title: Add Inline Styling to Elements
required:
- src: 'https://cdnjs.cloudflare.com/ajax/libs/d3/4.3.0/d3.min.js'
challengeType: 6
videoUrl: ''
localeTitle: 向元素添加内联样式
---
## Description
D3允许您使用style()
方法在动态元素上添加内联CSS样式。 style()
方法将逗号分隔的键值对作为参数。这是一个将选择的文本颜色设置为蓝色的示例: selection.style("color","blue");
## Instructions
将style()
方法添加到编辑器中的代码中,使所有显示的文本都具有verdana
的font-family
。
## Tests
```yml
tests:
- text: 你的h2
元素应该有verdana的font-family
。
testString: 'assert($("h2").css("font-family") == "verdana", "Your h2
elements should have a font-family
of verdana.");'
- text: 您的代码应使用style()
方法。
testString: 'assert(code.match(/\.style/g), "Your code should use the style()
method.");'
```
## Challenge Seed
## Solution
```js
// solution required
```