example
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<link rel="stylesheet" href="main.css" />
</head>
<body>
<div id="container">
<div id="scroll-container-one">
<div class="box-one">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Suscipit,
assumenda quisquam. Minus culpa quo a esse nostrum, laborum aspernatur
ipsa nisi cum blanditiis facilis, minima unde soluta quos, dolorum
impedit!
</div>
<div class="box-two">
<div class="inside-box">
<div id="one">abooga</div>
<div id="two">awooga</div>
<div id="three">asooga</div>
</div>
</div>
<div class="box-three">box 3</div>
</div>
</div>
</body>
</html>
CSS
:root{
height: 100vh;
width: 100vw;
}
body{
background-color: green;
width: 100%;
height: 100%;
margin: 0;
}
#container{
width: 100%;
height: 100%;
background-color: red;
position: relative;
}
#scroll-container-one{
width: 1000px;
height: 500px;
overflow-y: scroll;
overflow-x: hidden;
background: green;
}
.box-one{
height: 600px;
background-color: purple;
font-size: 32px;
}
.box-two{
height: 1400px;
position: relative;
background-color: orange;
}
.inside-box{
height: 500px;
position: sticky;
top: 0;
background-color: white;
display: flex;
justify-content: space-between;
opacity: 1;
}
.inside-box div{
width: 300px;
height: 200px;
background-color: blue;
font-size: 40px;
animation: appear linear forwards;
animation-timeline: view(600px);
opacity: 0;
}
#one{
animation-range-start: 100px;
animation-range-end: 400px;
}
#two{
animation-range-start: 500px;
animation-range-end: 800px;
}
#three{
animation-range-start: 900px;
animation-range-end: 1200px;
}
@keyframes appear{
from{
opacity: 0;
}
to{
opacity: 1;
}
}
.box-three{
height: 1000px;
background-color: yellow;
}