CSS background properties are as follows:-
- background-color
- background-image
- background-repeat
- background-attachment
- background-position
Background Image:-
The background-image property specifies an image to use as the background of an element.
By default, the image is repeated so it covers the entire element.
The background image for a page can be set like this:-
body {
background-image: url("image url");
}
background-image: url("image url");
}
Note: When using a background image, use an image that does not disturb the text.
By default, the background-image property repeats an image both horizontally and vertically.
Some images should be repeated only horizontally or vertically, or they will look strange, like this
body {
background-image: url("gradient_bg.png");}
If the image above is repeated only horizontally (background-repeat: repeat-x;), the background will look better:
body {
background-image: url("cssimage.png");
background-repeat: repeat-x;}
body {
background-image: url("iimage.png");
background-repeat: no-repeat;}
In the example above, the background image is shown in the same place as the text. We want to change the position of the image, to change the image position we use background-position property.
body {
background-image: url("img_tree.png");
background-repeat: no-repeat;
background-position: right top;}
Background Color:-
Repeat Horizontally-
Some images should be repeated only horizontally or vertically, or they will look strange, like this
body {
background-image: url("gradient_bg.png");}
If the image above is repeated only horizontally (background-repeat: repeat-x;), the background will look better:
body {
background-image: url("cssimage.png");
background-repeat: repeat-x;}
Repeat Vertically-
To repeat an image vertically, set background-repeat:reapeat-y;
body {
background-image: url("cssimage.png");
background-repeat: repeat-y;}
background-image: url("cssimage.png");
background-repeat: repeat-y;}
Set position and no-repeat
Showing the background image only once is also specified by the backgroun-repeat property:body {
background-image: url("iimage.png");
background-repeat: no-repeat;}
In the example above, the background image is shown in the same place as the text. We want to change the position of the image, to change the image position we use background-position property.
body {
background-image: url("img_tree.png");
background-repeat: no-repeat;
background-position: right top;}
The background-color property specifies the background color of an element.
The background color of a page is set like this:-
body {
background-color: green;}
background-color: green;}
in CSS, a color is specified by:
- a valid color name - like 'green'
- a HEX value - like '#oosjo'
- an RGB value - like 'rgb(879,88,0)'
In the example below, the <h1>, <p>, and <div> elements have different background colors:
h1 {
background-color: green;}
div {
background-color: lightblue;}
p {
background-color: yellow;}
background-color: green;}
div {
background-color: lightblue;}
p {
background-color: yellow;}
If You have any Question you can Comment me. feel free to Contact Us about Your Questions Or suggestions.
0 comments:
Post a Comment
Thanks