freeCodeCamp/curriculum/challenges/russian/01-responsive-web-design/basic-css/use-a-css-class-to-style-an...

3.9 KiB
Raw Blame History

id title challengeType videoUrl localeTitle
bad87fee1348bd9aecf08806 Use a CSS Class to Style an Element 0 Используйте класс CSS для стилизации элемента

Description

Классы - многоразовые стили, которые можно добавить к элементам HTML. Вот пример объявления класса CSS:
<Стиль>
.blue-text {
цвет синий;
}
</ Стиль>
Вы можете видеть, что мы создали класс CSS, называемый blue-text в <style> . Вы можете применить класс к HTML-элементу следующим образом: <h2 class="blue-text">CatPhotoApp</h2> Обратите внимание, что в элементе style CSS имена классов начинаются с периода. В атрибуте класса HTML-элементов имя класса не включает период.

Instructions

Внутри элемента style измените селектор h2 на .red-text и обновите значение цвета от blue до red . Дайте вашему элементу h2 атрибут class со значением 'red-text' .

Tests

tests:
  - text: Ваш элемент <code>h2</code> должен быть красным.
    testString: 'assert($("h2").css("color") === "rgb(255, 0, 0)", "Your <code>h2</code> element should be red.");'
  - text: Ваш элемент <code>h2</code> должен иметь <code>red-text</code> .
    testString: 'assert($("h2").hasClass("red-text"), "Your <code>h2</code> element should have the class <code>red-text</code>.");'
  - text: В вашей таблице стилей должен быть объявлен класс <code>red-text</code> и его цвет будет красным.
    testString: 'assert(code.match(/\.red-text\s*\{\s*color\s*:\s*red;\s*\}/g), "Your stylesheet should declare a <code>red-text</code> class and have its color set to red.");'
  - text: 'Не используйте встроенные объявления стиля, такие как <code>style=&quot;color: red&quot;</code> в вашем элементе <code>h2</code> .'
    testString: 'assert($("h2").attr("style") === undefined, "Do not use inline style declarations like <code>style="color&#58; red"</code> in your <code>h2</code> element.");'

Challenge Seed

<style>
  h2 {
    color: blue;
  }
</style>

<h2>CatPhotoApp</h2>
<main>
  <p>Click here to view more <a href="#">cat photos</a>.</p>

  <a href="#"><img src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back."></a>

  <div>
    <p>Things cats love:</p>
    <ul>
      <li>cat nip</li>
      <li>laser pointers</li>
      <li>lasagna</li>
    </ul>
    <p>Top 3 things cats hate:</p>
    <ol>
      <li>flea treatment</li>
      <li>thunder</li>
      <li>other cats</li>
    </ol>
  </div>

  <form action="/submit-cat-photo">
    <label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
    <label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
    <label><input type="checkbox" name="personality" checked> Loving</label>
    <label><input type="checkbox" name="personality"> Lazy</label>
    <label><input type="checkbox" name="personality"> Energetic</label><br>
    <input type="text" placeholder="cat photo URL" required>
    <button type="submit">Submit</button>
  </form>
</main>

Solution

// solution required