JSFiddle - React, Tailwind, and code Playground

HTML

<div class="parent">
    <div class="child">
        Hello world
    </div>
</div>

<div class="wholePage"></div>

CSS

.parent {
    position: relative;
    z-index: 4; /*matters since it's sibling to wholePage*/
}

.child {
    position: relative;
    z-index:1; /*doesn't matter */
    background-color: white;
    padding: 5px;
}

.wholePage {
    position: absolute;
    z-index: 3;
    background-color: black;
    opacity: .5;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
}