JSFiddle - React, Tailwind, and code Playground

by NOVUSIDEA

HTML

<main>
    <section class="section">Section 1</section>
    <section class="section">Section 2</section>
    <section class="section">Section 3</section>
    <section class="section">Section 4</section>
    <section class="section">Section 5</section>
    <section class="section">Section 6</section>
    <section class="section">Section 7</section>
    <section class="section">Section 8</section>
    <section class="section">Section 9</section>
    <section class="section">Section 10</section>
</main>

<div id="SiteBackground"></div>

CSS

html, body, main {    
    height: 100%;
}

body {
    position: relative;
    margin: 0;
}

section {
    padding: 5rem 3rem;
    text-align: center;
}

section:first-child,
section:last-child {
    background: #333;
    color: #fff;
}

#SiteBackground {
    background: #444;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 1611px;
    z-index: -1;
    clip-path: polygon(0 calc(0% + 200px), 100% 100%, 0 100%);
}

JavaScript

var background = document.querySelector('#SiteBackground');

function setMainBackgroundDimensions() {

    var allSections         = document.querySelectorAll('section.section'),    
        firstSection        = allSections[0],
        lastSection  		= allSections[allSections.length - 2],
        backgroundTop       = (firstSection.offsetHeight + firstSection.offsetTop),
        backgroundHeight    = lastSection.offsetTop;      

    background.style.top 	= backgroundTop + 'px';
    background.style.height = backgroundHeight + 'px';

    console.log(allSections);
    console.log(firstSection);

}

window.onload = setMainBackgroundDimensions();
window.addEventListener('resize', setMainBackgroundDimensions);