Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Background Image | Decorative Effects
CSS Fundamentals
course content

Kursinhalt

CSS Fundamentals

CSS Fundamentals

1. Introduction to CSS
2. Text Styles
3. Box Model and Layout
4. Flexbox
5. Decorative Effects

book
Background Image

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

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.

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

html

index.html

css

index.css

copy

background-size

background-size specifies the size of an element's background image. It can be used to scale the image to fit the element, or to set a specific size for the background image.

  • auto keeps the background image at its original size (default);
  • cover scales the image to completely cover the element while maintaining its aspect ratio, possibly cropping parts of the image;
  • contain scales the image to fit entirely within the element while maintaining its aspect ratio, possibly leaving empty spaces;
  • value sets custom dimensions for the background image, such as 100px 50px or percentages like 50%.
html

index.html

css

index.css

copy

1. What does the background-image property do?

2. What does the background-repeat property do?

3. What property determines the position of an element's background image?

What does the `background-image` property do?

What does the background-image property do?

Wählen Sie die richtige Antwort aus

What does the `background-repeat` property do?

What does the background-repeat property do?

Wählen Sie die richtige Antwort aus

What property determines the position of an element's background image?

What property determines the position of an element's background image?

Wählen Sie die richtige Antwort aus

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 5. Kapitel 2
We're sorry to hear that something went wrong. What happened?
some-alt