1

I have a section set up like this:

<section id="fullpage">

</section>

html, body {
    height:100%;
    margin:0;
}

#fullpage { 
    background-image: url("sakura.png");
}

I have the sakura.png in the root directory but the image does not show up, I only see a white screen, what could be the problem?

Edit: I had to remove the quotes from background-image: url("sakura.png");

Missy
  • 11
  • 3
  • Yes it is in the same folder, background-color does work but images keep failing – Missy Oct 21 '17 at 09:12
  • Do you have file "sakura.png" in the same directory, as the file with this code section? – Stepan Novikov Oct 21 '17 at 09:14
  • Your question is looks like duplicate of - https://stackoverflow.com/questions/21374534/css-background-image-not-loading. Please check answers there, I think that removing quotes can help – Stepan Novikov Oct 21 '17 at 09:19
  • 4
    Possible duplicate of [CSS Background image not loading](https://stackoverflow.com/questions/21374534/css-background-image-not-loading) – Stepan Novikov Oct 21 '17 at 09:19

4 Answers4

1

Try this:

* {margin: 0; padding: 0; box-sizing: border-box}
html, body {height: 100%}

#fullpage {
  height: 100%;
  background-image: url('sakura.png');
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
}
<section id="fullpage"></section>

Also works like this:

  • #fullpage {height: 100vh}
  • html, body {width: 100vw; height: 100vh} and #fullpage {height: 100%}
VXp
  • 11,598
  • 6
  • 31
  • 46
0

Try giving a height to section.

#fullpage { 
     height: 100px;
     background-image: url("sakura.png");
}
Shubham Agrawal
  • 417
  • 3
  • 11
0

you need to add a width property to your #fullpage

#fullpage { 
     width:100px;
     height: 100px;
     background-image: url("sakura.png");
}
-1

Try adding / to the url like so:

#fullpage { 
    background-image: url("/sakura.png");
}

Also try adding a height/width to your section.