freeCodeCamp/curriculum/challenges/russian/04-data-visualization/data-visualization-with-d3/add-inline-styling-to-eleme...

1.8 KiB
Raw Blame History

id title challengeType forumTopicId localeTitle
587d7fa7367417b2b2512bc6 Add Inline Styling to Elements 6 301475 Добавить встроенный стиль в элементы

Description

D3 позволяет добавлять встроенные стили CSS для динамических элементов с помощью метода style() . Метод style() принимает в качестве аргумента пару ключ-значение, разделенную запятыми. Вот пример, чтобы задать цвет текста выбора синим: selection.style("color","blue");

Instructions

Добавьте метод style() в код в редакторе, чтобы весь отображаемый текст имел font-family verdana .

Tests

tests:
  - text: Your <code>h2</code> elements should have a <code>font-family</code> of verdana.
    testString: assert($('h2').css('font-family') == 'verdana');
  - text: Your code should use the <code>style()</code> method.
    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