How to stretch and scale the background with CSS?

Spread the love

Sometimes, we want to stretch and scale the background with CSS.

In this article, we’ll look at how to stretch and scale the background with CSS.

How to stretch and scale the background with CSS?

To stretch and scale the background with CSS, we can set the background-size property to cover.

For instance, we write

body {
  background-image: url(bg.jpg);
  background-size: cover;
}

to set the background-size property to cover to make the background image stretch to fit the whole body element.

Conclusion

To stretch and scale the background with CSS, we can set the background-size property to cover.

Leave a Reply

Your email address will not be published. Required fields are marked *