JSFiddle - React, Tailwind, and code Playground

by id0

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/randomcolor/0.5.2/randomColor.js"></script>
<script src="https://bundle.run/[email protected]"></script>
<div class="parent">
  <section>
    <h1>Section One</h1>
  </section>
  <section>
      <h1>Section Two</h1>
  </section>
  <section>
      <h1>Section Three</h1>
  </section>
  <section>
      <h1>Section Four</h1>
  </section>
  <section>
      <h1>Section Five</h1>
  </section>
</div>

SCSS

* {
	box-sizing: border-box;
}
html {
	font-family: sans-serif;
}
.parent {
	height: 100vh;
  overflow: scroll;
	scroll-snap-type: mandatory;
	scroll-snap-points-y: repeat(100vh);
	scroll-snap-type: y mandatory;
}
section {
	border-bottom: 1px solid white;
	padding: 1rem;
	height: 250vh;
	scroll-snap-align: start;
	text-align: center;
	position: relative;
}
h1	{
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	text-align: center;
	color: white;
	width: 100%;
	left: 0;
	font-size: calc(1rem + 3vw);
}

JavaScript

const gra = function(min, max) {
    return Math.random() * (max - min) + min;
}
const init = function(){
	let items = document.querySelectorAll('section');
	for (let i = 0; i < items.length; i++){
		items[i].style.background = randomColor({luminosity: 'light'});
	}
	/* cssScrollSnapPolyfill() */
}
init();