Search code examples
cssxampp

Why isn't a background picture found XAMPP?


body {
  background-image: url(/images/background.jpg);      
  background-position: center center;      
  background-repeat: no-repeat;      
  background-attachment: fixed;      
  background-size: cover;
}

enter image description here

For some reason I'm getting this error:

GET http://localhost/images/background.jpg 404 (Not Found)

And also I'm kind of confused why the link is http://localhost/images/background.jpg instead of http://localhost/[project_name]/images/background.jpg


Solution

  • I found the solution.

    1. I don't need to write '/' at the beginning of the path
    2. I need to go up on 1 level in catalog because I'm in css folder

    So the path should look like this:

    background-image: url(../images/background.jpg);