-1

In my style file, I have a background with a url that links to my image. But the image doesn't display on screen..

So, I have my image saved in:

public/img/coding.jpeg


And my Sass file saved in:

resources/assets/sass/style.scss

I have tried this code in my Sass file:

background: url("/public/img/coding.jpeg");

But that doesn't work. Why not..

  • Are you seeing a 404 in your inspector for this image? If so you're path to the image is incorrect. If it's 200, then you have a display issue, probably CSS. If 'public' is the actual html root directory, then your path should start with /img – Robert Wade Nov 24 '17 at 20:45
  • Yes I see a 404 error, but the problem is, the path is correct. This is the URL: http://mark.dev/public/img/coding.jpeg and there is no folder before public. – Mark Luiken Nov 24 '17 at 20:59
  • https://stackoverflow.com/questions/940451/using-relative-url-in-css-file-what-location-is-it-relative-to – Chay22 Nov 24 '17 at 21:21

1 Answers1

0

did you apply it to the body in your CSS? :)

body {
      background: url("/public/img/coding.jpeg");
}

you can also just apply it directly to your body tag...

<body background="/public/img/coding.jpeg"> 
</body>
Stephan D.
  • 254
  • 2
  • 12