CSS Backgrounds

CSS Backgrounds

CSS Backgrounds

👉 CSS Backgrounds

The background-color property specifies the background color of an element. image.png

👉 CSS background-image

The background-image property specifies an image to use as the background of an element. image.png

👉 CSS Background Image Repeat

By default, the background-image property repeats an image both horizontally and vertically.

Showing the background image only once is also specified by the background-repeat property: image.png

👉 CSS background-repeat Property

image.png

👉 CSS background-attachment Property

The background-attachment property specifies whether the background image should scroll or be fixed (will not scroll with the rest of the page):

CSS background-attachment Property👇 image.png

Example of fixed 👇

image.png

Example of scroll 👇 image.png

CSS background-position Property

👉 The background-position property sets the starting position of a background image.

Note:-

By default, a background-image is placed at the top-left corner of an element and repeated both vertically and horizontally.

Property Values of background-position👇

image.png

Example of position center👇 image.png

Example based on horizontal and vertical position👇 image.png

Example of right center👇 image.png

CSS background-size Property 👇

The background-size property specifies the size of the background images.

image.png

Example of length property👇 image.png

We can also use two images in background.

Example👇 image.png


image.png> Download our HTML & CSS Visual Treat! ebook Here: Click here