background-image not loading

3034 views css

For some reason it was working before, but I haven't changed anything in these files, and the background-image stopped loading. I mocked up a codepen to re-produce the problem:


<!DOCTYPE html>
<html lang="en">
    <meta charset="utf-8">
    <title>UI Project Wk - Home</title>
    <link href=",700" rel="stylesheet">

    <div class="coming-soon">
      <div class="notice">
        <h1>COMING SOON</h1>
        <p id="countdown-clock" ></p>


.coming-soon {
  background-image: url('');
  height: 100%;
  background-position: center;
  background-size: cover;
  position: relative;
  color: white;
  font-family: "Courier New", Courier, monospace;
  font-size: 25px;

.notice {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;

hr {
  margin: 50px auto;
  width: 40%;

Can anyone tell me why background-image isn't showing up?

answered question

If you had inspected your dom you would know that the .coming-soon element has a height of 0. You can either your html and body height to be 100%. or set your coming-soon height to be 100vh

1 Answer


To use height: 100%; the parent element must have a defined height. In the codepen, adding this works:

html, body {
    height: 100%;

posted this

Have an answer?


Please login first before posting an answer.