Answer the question
In order to leave comments, you need to log in
How to make friends height 100vh and chrome mobile?
The crux of the problem is that mobile chrome renders a height of 100vh given the height of the browser's navbar. Naturally, it turns out that any picture, slider, etc. that has a height of 100vh is cut off. I googled and didn't google anything.. How to solve this problem?
Answer the question
In order to leave comments, you need to log in
Here is a super solution https://css-tricks.com/the-trick-to-viewport-units...
For myself, I solved this problem in this way:
body {
margin: 0;
overflow: hidden;
}
body > .scroll-box {
position: relative;
left: 0;
right: 0;
height: 100%;
max-height: 100vh;
overflow-y: auto;
}
$modal.on('show', () => $scrollBox.css({ 'pointer-events': 'none' }));
$modal.on('hide', () => $scrollBox.css({ 'pointer-events': 'auto' }));
The only way to solve it is by subtracting the height of the navbar from the height of 100vh.
The method is not 100%, because The height of the navigation for different devices may differ, but not drastically. I didn't find any other solution :)
mobile chrome render height 100vh given browser navbar height
Someone will need a solution to the height 100vh problem
const appHeight = () => {
const doc = document.documentElement
doc.style.setProperty('--app-height', '${window.innerHeight}px')
}
window.addEventListener('resize', appHeight)
appHeight()
:root {
--app-height: 100%;
}
html,
body {
padding: 0;
margin: 0;
overflow: hidden;
width: 100vw;
height: 100vh;
@media not all and (hover:hover) {
height: var(--app-height);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question