Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Фонове Зображення | Декоративні Ефекти
Основи CSS
course content

Зміст курсу

Основи CSS

Основи CSS

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

book
Фонове Зображення

background-image property allows us to add an image as the background of an HTML element. The basic syntax is so simple:

css

As a value for the background-image property, we use url(), and inside these brackets, we specify the image url.

html

index.html

css

index.css

copy

background-repeat

It determines if the image will be repeated horizontally, vertically, both or not at all.

css
html

index.html

css

index.css

copy

background-position

background-position is used to set the starting position of a background image within an element's background area. This property allows us to specify where the background image should be placed and how it should be positioned relative to the element. We have to set the position on the x and y axis

css
html

index.html

css

index.css

copy
  • auto - значення за замовчуванням, яке встановлює фонове зображення у початковий розмір.

  • cover - масштабує фонове зображення так, щоб воно повністю покривало елемент зі збереженням його співвідношення сторін. Це може призвести до обрізання деяких частин зображення, якщо співвідношення сторін елемента та зображення відрізняється.

  • contain - масштабує фонове зображення так, щоб воно повністю покривало елемент зі збереженням його співвідношення сторін. Це може призвести до того, що навколо зображення будуть помітні порожні місця, якщо співвідношення сторін елемента та зображення відрізняється.

  • value - задає ширину та висоту фонового зображення.

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

  • auto - default value, which sets the background image to its original size;

  • cover - scales the background image to completely cover the element while maintaining its aspect ratio. This may cause some parts of the image to be cropped if the aspect ratio of the element and the image are different;

  • contain - scales the background image to fit the entire element while maintaining its aspect ratio. This may cause empty spaces to be visible around the image if the aspect ratio of the element and the image are different;

  • value - sets the width and height of the background image.

For this example, we will use the bigger picture than we need as we wish to consider the behavior difference of each value for the background-size property.

html

index.html

css

index.css

copy

1. Що робить властивість background-image?

2. Що робить властивість background-repeat?

3. Яка властивість визначає положення фонового зображення елемента?

question mark

Що робить властивість background-image?

Select the correct answer

question mark

Що робить властивість background-repeat?

Select the correct answer

question mark

Яка властивість визначає положення фонового зображення елемента?

Select the correct answer

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

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

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

Секція 5. Розділ 2

Запитати АІ

expand
ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

course content

Зміст курсу

Основи CSS

Основи CSS

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

book
Фонове Зображення

background-image property allows us to add an image as the background of an HTML element. The basic syntax is so simple:

css

As a value for the background-image property, we use url(), and inside these brackets, we specify the image url.

html

index.html

css

index.css

copy

background-repeat

It determines if the image will be repeated horizontally, vertically, both or not at all.

css
html

index.html

css

index.css

copy

background-position

background-position is used to set the starting position of a background image within an element's background area. This property allows us to specify where the background image should be placed and how it should be positioned relative to the element. We have to set the position on the x and y axis

css
html

index.html

css

index.css

copy
  • auto - значення за замовчуванням, яке встановлює фонове зображення у початковий розмір.

  • cover - масштабує фонове зображення так, щоб воно повністю покривало елемент зі збереженням його співвідношення сторін. Це може призвести до обрізання деяких частин зображення, якщо співвідношення сторін елемента та зображення відрізняється.

  • contain - масштабує фонове зображення так, щоб воно повністю покривало елемент зі збереженням його співвідношення сторін. Це може призвести до того, що навколо зображення будуть помітні порожні місця, якщо співвідношення сторін елемента та зображення відрізняється.

  • value - задає ширину та висоту фонового зображення.

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

  • auto - default value, which sets the background image to its original size;

  • cover - scales the background image to completely cover the element while maintaining its aspect ratio. This may cause some parts of the image to be cropped if the aspect ratio of the element and the image are different;

  • contain - scales the background image to fit the entire element while maintaining its aspect ratio. This may cause empty spaces to be visible around the image if the aspect ratio of the element and the image are different;

  • value - sets the width and height of the background image.

For this example, we will use the bigger picture than we need as we wish to consider the behavior difference of each value for the background-size property.

html

index.html

css

index.css

copy

1. Що робить властивість background-image?

2. Що робить властивість background-repeat?

3. Яка властивість визначає положення фонового зображення елемента?

question mark

Що робить властивість background-image?

Select the correct answer

question mark

Що робить властивість background-repeat?

Select the correct answer

question mark

Яка властивість визначає положення фонового зображення елемента?

Select the correct answer

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

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

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

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