Hi there
This is my JSfiddle
I am trying to set background-image on a div but its not working
where is wrong?
Thanks
Hi there
This is my JSfiddle
I am trying to set background-image on a div but its not working
where is wrong?
Thanks
Hi again
Image is there, actually
But your div is too small, so it fits on the white background in the top-left corner of the image completely
Thanks @megazoid
good morning
Ok there is one more problem
I want to give Image a relative path from my drive
this is how I stored my files in my computer
when I try to give file URL
from css like this
/**Set the background-image on second tabs **/
#tab2{
background-image:url("/images/Desert.jpg");
height:500px;
width:500px;
}
then it shows an error on my console like this
How can I give relative path from my project directory
I am not using any backend lenguage like php or JSP or other
I am using JavaScript only
Relative path shouldn’t start with slash, only absolute paths do that.
If your css file is in “css” folder, what should it do to reach an image?
So, if you combine these steps you’ll get a relative path: ../images/Desert.jpg
background-image:url("../images/Desert.jpg");
Thanks
Is there any way so that I can configure height and width of an Image according to window size available?
You can either use background-size property with % values:
backround-size: 100% 100%;
or use media queries to define different sizes (or even images) for each screen size:
@media (max-width: 600px) {
.tab2 {
/* if window width <= 600px
set different background size or image here */
}
}
background is repeating
How to fix it?
background-repeat: no-repeat;
Thanks
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.