Monday 13 February 2023

How to solve 100vh problem in mobile

<script>
const appHeight = () => {
    const doc = document.documentElement
    doc.style.setProperty('--app-height', `${window.innerHeight}px`)
}
window.addEventListener('resize', appHeight)
appHeight()
</script>


:root {
    --app-height: 100%;
 }
 
 html,
 body {
     padding: 0;
     margin: 0;
     overflow: hidden;
     width: 100vw;
     height: 100vh;
     height: var(--app-height);
 }