Monday 25 March 2013

Learn CSS with Webtey(Part-IV) CSS background properties


Background Color


The background-color property defines the background color of an element. It is defined in the body selector: Example


body {background-color:red;}
    The background color can be specified by:
  • name - a color name, like "yellow"
  • RGB - an RGB value, like "rgb(100,120,0)"
  • Hex - a hex value, like "#cococo" In the example below, the h1, p, and div elements have different background colors:

    h1 {background-color:yellow;}
    p {background-color:#cococo;}
    div {background-color:rgb(255,0,0);}



This property is used to provide your background with and image
The code is like this:


 
body {
background-image:url('back.gif');
}



Background Image - Repeat Horizontally or Vertically

Let us see how will background looks if we repeat the image horizontally (repeat-x). By default, the background-image property repeats an image both horizontally and vertically.


body {
 background-image:url('back.png'); background-repeat:repeat-x; 
}


Let us see can we place image vertically ?? ofcourse we can so let us proceed
For repeating vertically we use (repeat-y)


body {
 background-image:url('back.png'); background-repeat:repeat-y; 
}  
Webtey VJ

No comments:

Post a Comment