How to stretch the background image to fill a div with CSS?

Spread the love

Sometimes, we want to stretch the background image to fill a div with CSS.

In this article, we’ll look at how to stretch the background image to fill a div with CSS.

How to stretch the background image to fill a div with CSS?

To stretch the background image to fill a div with CSS, we sdeyt the background-size property.

For instance, we write

div {
  background-size: 100% 100%;
}

to set the background-size to 100% 100% to make the background image fill the div.

Conclusion

To stretch the background image to fill a div with CSS, we sdeyt the background-size property.

Leave a Reply

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