title: horizontal layout when scroll
body: <p>I want to have a horizontal layout in my page ... whenever user scrolls the page instead of top-to-bottom
  layout I want to have left-to-right layout
  ... with my code on big screens there is empty space after last section and on small screens
  last section won't appear.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>calcBodyHeight();
  
  function calcBodyHeight() {
    const sections = document.querySelectorAll('.section');
    let height = null;
    sections.forEach(section =&gt; {
      height += section.offsetWidth;
    })
    document.body.style.height = `${height}px`;
  }
  const container = document.querySelector('.container');
  window.addEventListener('scroll', e =&gt; {
    const scroll = window.scrollY;
    container.style.left = `-${scroll}px`;
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>html,
  body {
    height: 100%;
  }
  
  body {
    overflow-x: hidden;
    overflow-y: auto;
  }
  
  .container {
    width: fit-content;
    height: 100vh;
    display: flex;
    position: fixed;
    left: 0;
    top: 0;
  }
  
  .container .section {
    width: 100vw;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  
  .container .section:nth-child(1) {
    background-color: cornflowerblue;
  }
  
  .container .section:nth-child(2) {
    background-color: coral;
  }
  
  .container .section:nth-child(3) {
    background-color: lightgreen;
  }
  
  .container .section:nth-child(4) {
    background-color: teal;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="container"&gt;
    &lt;div class="section"&gt;&lt;/div&gt;
    &lt;div class="section"&gt;&lt;/div&gt;
    &lt;div class="section"&gt;&lt;/div&gt;
    &lt;div class="section"&gt;&lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>