Sobes.tech
Junior

What are the possible values of the background-size property?

sobes.tech AI

Answer from AI

auto, contain, cover, <length>, <percentage>.

  • auto: The image retains its original proportions.
  • contain: Resizes the image to fit entirely within the element while maintaining aspect ratio.
  • cover: Resizes the image to cover the entire element while maintaining aspect ratio. The image may be cropped.
  • <length>: Explicitly sets the width and/or height of the image in length units (e.g., px, em, rem). One or two values can be specified.
  • <percentage>: Explicitly sets the width and/or height of the image as a percentage of the element's size. One or two values can be specified.

If one value is specified, it sets the width, and the height is automatically calculated to maintain proportions. If two values are specified, the first sets the width, and the second sets the height.