CSS - Background Size

CSS Background Size

In this tutorial, I will be showing you all you need to know about background-size property in CSS.

The background-size property is used set the size of the background image.

Property Values

  • contain - This value is used to make the background image fully visible inside the element's container.
  • cover - This value is used to make the background image to occupy or cover the entire element's container. Using this value, the image might stretch or cut off some edges while resizing.
  • auto - This value is used to make the background image maintain its original size even if it doesn't cover the entire element's container. (Default Value)
  • initial - This sets the property value to the default value.
  • inherit - This sets the property value to the parent element value.
  • absolute and relative unit values - These can also be used to set background size.
  • note
    NOTE:

    The first value sets the width, while the second value sets the height. If only one value is specified, the height value will be set to auto.

ADVERTISEMENTS

LEARNING IS A CONTINOUS PROCESS - PRACTICE MAKES PERFECT