JSFiddle - React, Tailwind, and code Playground

HTML

<div id="frame"></div>

<div class="item" style="background-color:red"></div>
<div class="item" style="background-color:green;top:50%"></div>
<div class="item" style="background-color:blue;top:20%;left:30%"></div>
<div class="item" style="background-color:pink;top:60%;left:20%"></div>
<div class="item" style="background-color:yellow;top:25%;left:10%"></div>

CSS

#frame{
 height:10rem;
 width:10rem;
 display:inline-block;
 resize:both;
 border: solid black 0.5rem;
 overflow: auto;
 position:absolute;
 
 z-index:1;
}

.item{
  height:2rem;
  width:2rem;
  position:absolute;
}

JavaScript

console.log(within_frame())

function within_frame(){
 //returns all the elements within the frame bounds
}