How can I get my site to look like this? Where the first section fills the whole screen, then when you scroll down ANOTHER section fills the whole screen. https://pharmacy.cargo.site/
I tried doing a width/height 100%, but no luck. I tried styling an entire div with a background color, also no luck.
3
Answers
If you view the page source on the "Nested Scrollers" link below you can see the implementation of
vh
as mentioned by wouch.They are also using scrollMonitor library, which can be found here: https://github.com/stutrek/scrollmonitor
See their demo for Nested Scrollers. Your are not interested in the nested scrollers themselves, but the three sections that contain them.
User @Leland pointed out
dvh
and indeed, it seems to work just fine – thanks for pointing that out. It was always annoying to work withvh
.Last time I checked this feature, it was not supported enough (see bug report for Safari 15.6 https://caniuse.com/?search=Small%2C%20Large%2C%20and%20Dynamic%20viewport%20units. Now it seems to be fine – unless you need to support IE11.
For a full view scroll construction you need to:
html
andbody
consume the full viewport space available.scroll-container
).scroll-container > section
)Optionally you can introduce CSS Scroll Snap for full container scrolling (read ‘full page’ in your case).
snippet