<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.container{
border: 2px solid black;
height: 15500px;
background:khaki;
}
/* CSS postition: static (default), absolute, relative, fixed, sticky */
.box{
display: inline-block;
border: 2px solid red;
width: 150px;
height: 150px;
margin: 2px;
}
#box3{
/* relative: relative gives gap to its normal position */
/* position: relative; */
/* absolute: relative to the position of its first parent*/
/* position: absolute; */
/* top: 34px;
left: 155px; */
position:sticky;
top: 9px;
}
</style>
</head>
<body>
<div class="container">
<div class="box" id="box1">1</div>
<div class="box" id="box2">2</div>
<div class="box" id="box3">3</div>
<div class="box" id="box4">4</div>
</div>
</body>
</html>