CSS Background Image Not Displaying

后端 未结 15 2039
[愿得一人]
[愿得一人] 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 10:06

    I have the same issue. But it works properly for me

    background: url(../img/debut_dark.png) repeat
    
    0 讨论(0)
  • 2020-12-16 10:08

    Make sure your body has a height, f.ex:

    body { 
        background: url(/img/debut_dark.png) repeat;
        min-height: 100%;
    }
    
    0 讨论(0)
  • 2020-12-16 10:08

    If your path is correct then I think you don't have any element in you body section. Just define the height of the body and your code will work.

    0 讨论(0)
  • 2020-12-16 10:09

    I had the same issue. For me it worked with:

      background: url("../img/green.jpg") no-repeat center bottom/cover;
      height: 100vh;
    
    0 讨论(0)
  • 2020-12-16 10:12
    background : url (/img.. )
    

    NOTE: If you have your css in a different folder, ensure that you start the image path with THE FORWARD SLASH.

    It worked for me. !

    0 讨论(0)
  • 2020-12-16 10:13

    You have to use a relative path in the URL. I think you made two folders in the root directory where your index.html resides. One is 'CSS' folder & another is 'img' folder.

    Now, if you have to access 'img' folder in css files. So you have to go back once in root directory using "../" syntax. Then move to the 'img' folder using "../img" syntax. Then write the image name "../img/debut_dark.png".

    body { 
        background: url("../img/debut_dark.png") repeat 0 0;
    }
    
    0 讨论(0)
提交回复
热议问题