codescracker


css

CSS Background Size



« Previous Tutorial Next Tutorial »


The background-size Property

The background-size property is used to specify the size of the image that is used as a background for an element.

You can specify the size by using any of the following values:

CSS auto Keyword

Sets the image to its original size. Some examples of using the auto keywords to specify the size are given as follows:

background-size: auto;
background-size: auto auto;

CSS Length Parameter

Sets an image of specified size in terms of height and width. Some examples of using the background-size property to specify length parameter of an image are given as follows :

background-size: 15px;
background-size: 50px 100px;

CSS Percentage Parameter

Sets the size of an image with respect to the specified height and width of the area in which the image has to be displayed. Some examples of using the percentage parameter to specify the size are given as follows :

background-size: 50%;
background-size: 50% auto;

Note - The size of a background image cannot be defined in negative values, but a zero size image is allowed; however, it will not be displayed.


« Previous Tutorial Next Tutorial »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test