Solution 1 :

If you want to use percentage for your height, you could add a little (:after), and set a padding according to your desired proportion.

.page-wrapper {
    height: 100%;
}

.div-page-image {
    background-image: url('https://source.unsplash.com/random');
    background-size: cover;
    background-repeat: no-repeat;
}

.div-page-image:after {
   content: "";
   padding-top: 65%;
   display: block
}
<div class="page-wrapper">
    <div class="div-page-image">

    </div>
</div>

Problem :

The background image isn’t showing… (I also have a navbar if that’s uh? important)

So this is the current code I have right now:

<div class="page-wrapper">
    <div class="div-page-image">

    </div>
</div>

.page-wrapper {
    height: 100%;
}

.div-page-image {
    background-image: url('./pictures/city.png');
    width: 100%;
    height: 20%;
}

Comments

Comment posted by epascarello

Look at network tab, do you see the image request?

Comment posted by imgur.com/a/093a4fW

@epascarello

Comment posted by callOfCode

Does parent of page-wrapper have relative position and size specified?

Comment posted by j08691

Isn’t that a broken image in the dev tools?

Comment posted by lasseesharp

@callOfCode No but I added it, no difference.

By