Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workarounds for tip on viewport height #146

Open
NateWr opened this issue May 26, 2023 · 2 comments
Open

Workarounds for tip on viewport height #146

NateWr opened this issue May 26, 2023 · 2 comments

Comments

@NateWr
Copy link

NateWr commented May 26, 2023

Thanks for this. I'm experimenting now and learning the ins-and-outs of scrolling. The readme includes this tip:

Avoid using viewport height (vh) in your CSS because scrolling up and down constantly triggers vh to change, which will also trigger a window resize.

I presume you're referring to how mobile browsers show/hide the navbar in the app when the user scrolls "back up". Is that a correct assumption? Do you have any suggestions for workarounds? I use vh quite a bit and I'm struggling to imagine a good alternative that scales with the user's device.

For example, if I want a block to sit stickied in the middle of the screen while other stuff scrolls by, wouldn't I need to use 100vh on the parent container? Here's a simple example:

https://codepen.io/natewr/pen/WNaWvoL

@hacknug
Copy link

hacknug commented Oct 16, 2023

Not sure if the readme refers to what you mentioned but in case it does I think there's two approaches that could work:

@JPrisk
Copy link

JPrisk commented Jan 31, 2024

you could use svh which is well supported now https://caniuse.com/viewport-unit-variants

the tailwindcss docs explain it really well https://tailwindcss.com/docs/height#small-viewport-height

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants