JSFiddle - React, Tailwind, and code Playground

by Felix Fong

HTML

<p>
 Test
</p>
<div class="container">
  <div class="item"><div></div><div></div><div></div></div>
  <div class="item"><div></div><div></div><div></div></div>
  <div class="item"><div></div><div></div><div></div></div>
</div>


<div class="container real">
  <div class="item"><div></div><div></div><div></div></div>
  <div class="item"><div></div><div></div><div></div></div>
  <div class="item"><div></div><div></div><div></div></div>
  <div class="item"><div></div><div></div><div></div></div>
  <div class="item"><div></div><div></div><div></div></div>
  <div class="item"><div></div><div></div><div></div></div>
  <div class="item"><div></div><div></div><div></div></div>
  <div class="item"><div></div><div></div><div></div></div>
</div>

SCSS

/* In practice this is also a flex item, with size dependent on parent, and ultimately window viewport */
/* Contents might not be display flex, e.g. just regular text/block items, or a table */
.container { 
  width: 200px;
  height: 200px;
  overflow: auto;
  border: 1px solid black;
}
.item {
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: row;
  background: black;
  height: 50px;
  border: 1px solid cyan;
  > *{
    flex: 1 1 auto;
  }
  > :nth-child(1) {
    background: red;
  }
  > :nth-child(2) {
    background: green;
  }
  > :nth-child(3) { /* allow to go behind scrollbar */
    background: blue;
    flex: 0 0 20px; /* somehow equal to the browsers scrollbar size */
  }
}

JavaScript

$(function(){

	$container = $('.container.real')
  
  $container.append('<div style="height:100px;"></div>')

});