adding a background image to a div code example
Example 1: div background image
#avatar {
background-image: url('http://i.stack.imgur.com/Dj7eP.jpg');
width: 150px;
height: 150px;
background-size: cover;
background-position: top center;
border-radius: 50%;
}
Example 2: background image
div {
background-color: #ffffff;
background-image: url("img_tree.png");
background-repeat: no-repeat;
background-attachment: scroll|fixed|local|initial|inherit;
background-position: right top | x% y% | xpos ypos;
background-clip: border-box|padding-box|content-box|initial|inherit;
background-size: auto|length|cover|contain|initial|inherit;
}
//shorthand:
div {
background: #ffffff url("img_tree.png") no-repeat right top;
}
Example 3: how to set div background image
body {
background-image: url("paper.gif");
background-color: #cccccc;
}
Example 4: css background image
body {
background-image: url("paper.gif");
}