JSFiddle - React, Tailwind, and code Playground

by Pangur Ban

HTML

<div class="viewport">
  
  <div class="scroll">
    <div class="dom">dom</div>
  </div>
  
  <div class="canvas"></div>
  
</div>

CSS

body,html {
  height: 100%;
  margin: 0;
}

.viewport,
.scroll {
  height: 100%;
}

.viewport {
  position: relative;
}

.scroll {
  display: flex;
  justify-content: center;
  overflow: auto;
}

.dom,
.canvas {
  width: 200px;
  height: 200px;
}

.dom {
  background: rgba(0,0,0,0.1);
  height: 2000px;
}

.canvas {
  position: absolute;
  background: rgba(0,0,0,0.2);
  top: 30px;
  left: 40px;
}