Wednesday, 26 October 2011

All CSS Background Properties


This property is used to format the background of any html element.

Property
Description
Values
CSS
Background
Sets all the background properties in one declaration
background-color
background-image
background-repeat background-attachment background-position
inherit
1
Background-attachment
Sets whether a background image is fixed or scrolls with the rest of the page
Scroll
fixed
inherit
1
Background-color
Sets the background color of an element
color-rgb
color-hex
color-name
transparent
inherit
1
Background-image
Sets the background image for an element
url(URL)
none
inherit
1
Background-position
Sets the starting position of a background image
top left
top center
top right
center left
center center
center right
bottom left
bottom center
bottom right
x% y%
xpos ypos
inherit
1
Background-repeat
Sets if/how a background image will be repeated
Repeat
repeat-x
repeat-y
no-repeat
inherit
1


Example - 1

<html>
<head>
     <style type=”text/css”>
              body
              {
                        background-color:blue;
              }
     </style>
</head>
<body>
     Hello World
</body>
</html>

Example - 2

<html>
<head>
     <style type=”text/css”>
              body
              {
                        background-image:url(sunset.jpg) repeat;
                        background-position:top left;
                        background-attachment:fixed;
              }
     </style>
</head>
<body>
     Hello World
</body>
                 </html>

No comments:

Post a Comment