JSFiddle - React, Tailwind, and code Playground

HTML

<div class="container">
  <div class="sidebar">
    <div class="element">
      <div class="first"></div>
      <div class="second">
        <div class="second-absolute"></div>
      </div>
    </div>
    <div class="element">
      
    </div>
    <div class="element">
      
    </div>
    <div class="element">
      
    </div>
  </div>
</div>

CSS

.container {
  max-height: 500px;
  background: grey;
}

.sidebar {
  height: 100vh;
  width: 150px;
  overflow-x: scroll;
  overflow-y: auto;
  background: red;
}

.element {
  position: relative;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  margin: 5px;
  height: 200px;
  width: 20px;
  background: green;
}

.first {
  position: relative;
  display: block;
  height: 20px;
  width: 100px;
  background: pink;
}

.second {
  display: inline-block;
}

.second-absolute {
  position: absolute;
  height: 20px;
  width: 250px;
  background: purple;
}