set background image to div css code example
Example 1: css background image
background-image: url("image.png");
background-position: center;
background-repeat: no-repeat;
background-size: cover;
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: background image css
.selector {
background-image: url(image.png);
}
Example 4: make image background of div
background-image: url("photographer.jpg");
Example 5: how to set div background image
body {
background-image: url("paper.gif");
background-color: #cccccc;
}