If you guys/gals are wondering how to have your hero section FILL perfectly in the browser viewport no matter the height of the browser window (usually it is 800px, but some monitors are taller) like in these screenshots below:
Taller monitor or browser window:
Smaller monitor or browser window (notice the icon on the bottom sticking to the bottom):
Method #1
While CSS is typically not very adept at working with browser height (because of document vs. window heights), we can add some JavaScript to help get us there.
First, add this in your dashboard, under the </body>
tag section:
<script>
Webflow.push(function () {
var fulls = $('.full-page');
var win = $(window);
Webflow.resize.on(function () {
fulls.height(win.height());
});
});
</script>
Then, you’ll need to be sure and set any of the “full-page” sections to overflow:hidden
, because otherwise they might show a nested scrollbar.
Finally –the tricky part– you’ll need to style your inner elements using absolute or (explicitly) relative positions. This means instead of using margins, you’ll need to set top and bottom to percentage values to achieve a vertical fluid layout.
Method #2
Here’s an attempt at building this purely in Webflow without any JS.
Webflow designer link here.
Few points to keep in mind:
- Body height must be set to 100%
- Section height must be 100% and the position must be set to relative.
- Divs within section must have an absolute position, using
%
units.
Thanks to @danro for these tricks!
Using "vh"
unit
I know I’m late to the party, but there’s a new CSS unit called “vh” (vertical height) that might be useful. If you want to use it in Webflow, just type “50vh” into the Height field, and it should switch to use that. It seems to be supported back to IE9 (Viewport units: vw, vh, vmin, vmax | Can I use... Support tables for HTML5, CSS3, etc).
Thanks @callmevlad for this addition.
Original forum topic: