Skip to content

Instantly share code, notes, and snippets.

@sanrandry
Last active September 19, 2023 15:24
Show Gist options
  • Save sanrandry/676ff7712d50444425878f2d9dcd6f76 to your computer and use it in GitHub Desktop.
Save sanrandry/676ff7712d50444425878f2d9dcd6f76 to your computer and use it in GitHub Desktop.
calculate navbar height
  • add this javascript
document.documentElement.style.setProperty('--nav-height', document.getElementById("navbar").offsetHeight);
  • use property iny css
:root {
    --nav-height: 70px; /*You HAVE To Give A Default Fallback Value*/
}

.container-fs{
    width: 100vw;
    height: calc(100vh - var(--nav-height));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment