There is such a problem: I've been trying to put a picture-background on a div for a week already. But nothing is displayed in the browser. Because of this, I can not put the project. Why does not it work?

 .game1 { width: 100%; height: 450px; background-image: url("screenshot.jpg"); background-repeat: no-repeat; background-size: cover; } 
 <div class="game1"> <p class="name"> Бла </p> <p class="description"> Бла <br> бла <br> бла бла бла! </p> <br> <br> <br> <a href="games/radiation.php"> <button id="b1"> Перейти </button> </a> </div> <br> <br> <br> <br> 

I put the picture in the root of the site, in the folder with CSS , and uploaded it to the server, wrote the URL via http , does not work.

Closed due to the fact that off-topic by the participants of KAGG Design , mymedia , Alexey Shimansky , Cheg , br3t 13 Aug '17 at 7:47 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reasons:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - mymedia, Alexey Shimansky, br3t
  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - KAGG Design, Cheg
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • one
    Learn how to use the Google Chrome debugger (F12). Networks section will help you to understand why the picture is not loading - Stanislav Hmelevsky
  • one
    Make the code executable and reproduce your problem there. - neluzhin

3 answers 3

And what can not work here?

 .game1 { width: 100%; height: 450px; background-image: url(https://i.kinja-img.com/gawker-media/image/upload/s--zTY0m0ci--/c_scale,fl_progressive,q_80,w_800/1359563471926476945.jpg); background-repeat: no-repeat; background-size: cover; } .game1 p { color: #fff; } 
 <div class="game1"> <p class="name"> Бла </p> <p class="description"> Бла <br> бла <br> бла бла бла! </p> <br> <br> <br> <a href="games/radiation.php"> <button id="b1"> Перейти </button> </a> </div> <br> <br> <br> <br> 

  • I want to know this - ZerZ
  • Make a non-working snippet, you have already written. In other words, create a minimal, self-contained and reproducible example: ru.stackoverflow.com/help/mcve - KAGG Design

Try adding! Important before; in css background-image

    Make an img folder, put this picture in there and make this way if you have a file with styles in the css folder.

     background-image: url("../img/screenshot.jpg"); 
    • I have an images folder, the path I wrote. Need to try again. - ZerZ