<!DOCTYPE html>

<html>
<head>
<style>
    body {
        margin: 0;
    }
    .container {
        width: 200px;
        height: 400px;
        outline: 2px solid black;
    }
    
    .box {
        width: 200px;
        height: 200px;
    }

    .sticky {
        position: sticky;
    }
    
    .intermediate {
        position: absolute;
        z-index: 1;
        background-color: green
    }
    
    .child {
        position: relative;
        background-color: red;
        z-index: 2;
    }
    
    .indicator {
        position: absolute;
        top: 0;
        left: 0;
        background-color: blue;
        z-index: 0;
    }
</style>
</head>
<body>
    <div class="indicator box"></div>
    <div class="container">
        <div class="intermediate box"></div>
        <div class="sticky box">
            <div class="child box"></div>
        </div>
    </div>
</body>
</html>
