CSS Background Image Not Displaying

后端 未结 15 2041
[愿得一人]
[愿得一人] 2020-12-16 09:20

I have an HTML file with a subdirectory called img with an image called debut_dark.png. In my CSS file, I have:

body { 
    backgro         


        
15条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-16 09:57

    Basically the problem is with file path. The forward slash in the beginning of the url makes it look for the file at the root. Removing that, it will be a path relative to this css file - like this: background-image: url(img/debut_dark.png);

    If you are using Atom, copying the project path of image sometimes includes forward slash in the copied path so be careful.

提交回复
热议问题