1.5 KiB
1.5 KiB
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
587d7fa7367417b2b2512bc6 | Add Inline Styling to Elements | 6 | 向元素添加内联样式 |
Description
style()
方法在动态元素上添加内联CSS样式。 style()
方法将逗号分隔的键值对作为参数。这是一个将选择的文本颜色设置为蓝色的示例: selection.style("color","blue");
Instructions
style()
方法添加到编辑器中的代码中,使所有显示的文本都具有verdana
的font-family
。 Tests
tests:
- text: 你的<code>h2</code>元素应该有verdana的<code>font-family</code> 。
testString: assert($('h2').css('font-family') == 'verdana');
- text: 您的代码应使用<code>style()</code>方法。
testString: assert(code.match(/\.style/g));
Challenge Seed
<body>
<script>
const dataset = [12, 31, 22, 17, 25, 18, 29, 14, 9];
d3.select("body").selectAll("h2")
.data(dataset)
.enter()
.append("h2")
.text((d) => (d + " USD"))
// Add your code below this line
// Add your code above this line
</script>
</body>
Solution
// solution required