Search This Blog
Html tutorial, css tutorial, js tutorial, website creating tutorial, android app development tutorial, java tutorial, xml tutorial, programming tutorial
Featured
- Get link
- X
- Other Apps
CSS Background tutorial with all types and examples.
CSS - [BACKGROUNDS]
The CSS background properties are used to add background effects for elements. In this chapter you will learn to add background using CSS
In this chapter you will learn to add background using these syntax.
- background-color
- background-image
- background-repeat
- background-attachment
- background-position
- background (shorthand)
CSS [background-color]
background-color attribute in css is used to apply a solid color.
these all codes will insert a solid color.
body {
background-color:#20b0d5;
}
//insert color from hex value
#demo1 {
background-color:purple;
}
//insert color from color name
.demo2 {
background-color:rgb(255,0,0);
}
//insert color from rgb value
CSS [background-image]
background-image is used to attach a image as a background.
these codes will insert a image as a background.
body {
background-image:url("bg.png");
}
//insert img from device
.demo1 {
background-image:url("https
://arrangethefuture.blogspot.combr
/2022/02/tags-and
-attributes-how-to-use-tags
-and.html");
}
//insert img using internet
CSS [background-repeat]
after inserting a img you can use background-repeat attribute to repeat umg on a axis
you can copy paste these codes and see preview by own in any editor
body {
background-image:url("image.jpg");
background-repeat:repeat-x;
}
//repeat on x axis till last
.demo1 {
background-image:url("image.jpg");
background-repeat:repeat-y;
}
//repeat on y axis till last
#demo2 {
background-image:url("image.jpg");
background-repeat:no-repeat;
}
//will not repeat image if repeating
CSS [background-attachment]
after inserting a image you can select for it to be scrollable or fixed. this plays very important role while developing a webpage.
you can preview by copy + paste
.demo1 {
background-image:url("img.jpg")
background-attachment:fixed;
}
#demo2 {
background-image:url ("img.png");
background-attachment:scroll;
}
CSS [background-position]
this is helpful to give a position of img in screen.
can preview by copy + paste
.demo1 {
background-image:url("image.jpg");
background-position:right top;
}
.demo2 {
background-image:url("image.jpg");
background-position:center;
}
.demo3 {
background-image:url("image.jpg");
background-position:left bottom;
}
CSS Shorthand
this is used to apply css other attributes in one attributes.
preview by copy and paste
body {
background-color: #ffffff;
background-image: url("img_tree.png");
background-repeat: no-repeat;
background-position: right top;
}
avoid writing this lengthy code by.
body {
background: #ffffff url("img_tree.png")
no-repeat right top;
}
you can't change order of this Shorthand
otherwise code can't work.
- Get link
- X
- Other Apps
Popular Posts
Java tutorial. How to start with java. Tutorial
- Get link
- X
- Other Apps
Comments