CSS BACKGROUND

CSS BACKGROUND IS used to define the background effects of an element.

background Color

The attribute background-color is used to specify the background color of an element. For example:

body {background-color:yellow}

background image

The attribute background-image is used to specify the background image of an element. For example:

body {background-image:url(image.jpg)}

If the image is smaller than the size occupied by the element, then the image is repeated down to occupy the full height of the element.

If we repeat the image to the right instead of down, put the value "repeat-x" in attribute "background-repeat". For example:

body { background-image:url(image.jpg); background-repeat:repeat-x; }

If you do not want the image to be repeated, ie only appears once you, put the value "no-repeat" in attribute "background-repeat". For example:

body { background-image:url('image.jpg); background-repeat:no-repeat; }

background attachment

The attribute background-attachment is used to specify the position of the fund is fixed within the element or change the scroll position of the HTML page.

The default is

background-attachment:scroll;

To specify a fixed value:

background-attachment:fixed;

background position

The attribute background-position is used to indicate the position of the fund within the element.

The default value is "left top". This defines

background-position:left top

Some possible values are: left top, left center, bottom left, top right, center right, bottom right, center top, center center, center bottom

You can also specify a percentage of separation from "left top", for example 10% right and 20% down.

background-position:10% 20%

Instead of percentage, can also be expressed in pixels

background-position:50px 230px