I want to add background image in my css code but it's not loading. How to change or add background image in css please help I'm written css code in notpad++
Asked
Active
Viewed 4,143 times
5 Answers
4
.Your class name {
background-image: url("your image url");
background-repeat: no-repeat;
background-size: 100% 100%;
float: left;
width: auto;
}
Please try Above type of code in your css section.

Jainam
- 2,590
- 1
- 9
- 18
0
you can add that as this.
if you have id
#yourid{
background-image: url("your image url(EX:imge.jpg)");
}
if you have class
.yourclass_name{
background-image: url("your image url(EX:imge.jpg)");
}
you can use background function also...if you add background css function,you should have to change width and height
.yourclass_name {
background: url("img_tree.png") no-repeat;
height:500px or give to precentage(30% like that);
width:1000px or give to precentage (70%);
}

Sameera Madushanka
- 87
- 5
-
/* Here is my code still not working */ .bd { background-image: C:\Users\dell\Desktop\New folder("pic.jpg"); background-color:#cccccc; } – Sanjeev kumar Mar 23 '16 at 05:43
-
-
0
This is the path u should specify, The way to copy the path is to go the directory where the image is present, then copy path there.
body { background-image:url("C:\1.jpg");

Manish62
- 154
- 1
- 1
- 13
-
Do one thing, put the image in the same folder where html file is present. Then no need to specify path. Try it – Manish62 Mar 23 '16 at 06:02
0
If you want to add an image as background-image in CSS, there are two ways of doing it:-
- If you want to add an image from the internet then, you can use
background-image: url("your image url");
example:
background-image: url("https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQms3mJIPu3jlPy8b8cOmRg69qurCA82EBDofx6jaK11cUM6u4w");
- If you want to add an image from your pc, then you should write the image path i.e.,
background-image: url("your image path");
example:
background-image: url("C:\Users\Vimalendu Shekhar\Downloads\image.jpg");

Jesse
- 3,522
- 6
- 25
- 40