Reputation: 21
I have a problem which is my background image doesn't show up. I am sure that my url is correct (Because I have used this url in other aspects).
This is my css file:
body{
background : url(assets/image/main.jpg);
background-size: cover;
}
so what happened?
This is my folder's structure:
/assets/
css/
style.css
image/
main.jpg
/index.html
Upvotes: 0
Views: 78
Reputation: 491
Your code is correct. You should know that the path is relative to the location of the style (and not the html). The fact of having used this code elsewhere does not mean that the path is correct here.
After that may be the image which is corrupt.
Upvotes: 1
Reputation: 591
Remove the space between background :
and add quotes to your URL string so it looks like background: url("assets/image/main.jpg");
Beyond that just ensure that the filepath from this css file still maps to that folder correctly, just because it works in one css file doesn't mean it works in another if the folder structure differs.
Upvotes: 1