Skip to content

Instantly share code, notes, and snippets.

@saintsGrad15
Created September 19, 2022 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saintsGrad15/aad135ad03d4e72900222bcb35b774ce to your computer and use it in GitHub Desktop.
Save saintsGrad15/aad135ad03d4e72900222bcb35b774ce to your computer and use it in GitHub Desktop.
Cause body to fill the viewport, establish a CSS Grid with a header, left-nav and main body. The nav and body will scroll independently, the body will not scroll.
<template>
<div id="mainLayout">
<div id="header"></div>
<div id="leftNav"></div>
<div id="mainView"></div>
</div>
</template>
<style>
html, body { /* nothing necessary */ }
#mainLayout {
height: 100vh;
display: grid;
grid-template-columns: max-content 1fr;
grid-template-rows: max-content minmax(0, 1fr);
grid-template-areas:
"header header"
"nav main";
overflow-y: hidden;
}
#mainLayout > * {
min-height: 0;
}
#header { grid-area: header; }
#leftNav { grid-area: nav; }
#mainView { grid-area: main; }
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment