Skip to content

Instantly share code, notes, and snippets.

@infocities
Forked from sanrandry/caculate_navbar_height.md
Created September 19, 2023 15:24
Show Gist options
  • Save infocities/c15834c9ef32c0e8d33df744f6188570 to your computer and use it in GitHub Desktop.
Save infocities/c15834c9ef32c0e8d33df744f6188570 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