Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Ефективна Робота з CSS | Вступ до CSS
Основи CSS
course content

Зміст курсу

Основи CSS

Основи CSS

2. CSS для Тексту
3. Бокс Модель та Відстань між Елементами
4. Флексбокс
5. Декоративні Ефекти

book
Ефективна Робота з CSS

Щоб оголосити змінну, ми використовуємо псевдоклас :root у верхній частині нашого CSS-файлу і додаємо до імені змінної префікс --. Наприклад, давайте визначимо змінну --blue-color зі значенням #3f42f3 у нашому блоці :root:

css

Оголосивши змінну, ми можемо застосувати її до будь-якої властивості CSS за допомогою функції var(). Наприклад, щоб присвоїти властивості color елемента <h1> значення нашої змінної --blue-color, ми можемо написати

css

Let's combine the knowledge of variable declaration and usage in the following example:

html

index.html

css

index.css

copy

In this example, we define two variables, --background-color and --text-color, and apply them to the background-color and color properties, respectively. By changing the values of these variables, we can easily update the colors throughout the stylesheet.

Overriding Properties

Sometimes, we need to override specific properties in CSS to achieve the desired styling. This can be accomplished by declaring a property with the same name within a nested selector and assigning a new value.

Consider the following example of a traffic light with different color signals:

html

index.html

css

index.css

copy

By targeting the specific signal classes, we can fine-tune the color for each signal while maintaining the shared styles defined in the base .signal selector.

Орієнтуючись на конкретні класи сигналів, ми можемо точно налаштувати колір для кожного сигналу, зберігаючи при цьому загальні стилі, визначені в базовому селекторі .signal.

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 9
Ми дуже хвилюємося, що щось пішло не так. Що трапилося?
some-alt