Note: This behaviour is currently only observed in Safari, specifically because of how the tabs are presented in the browser. Firefox and Chrome are fine.
My page layout is as follows (just names shown):
<body>
<wrapper>
<header> ... </header>
<main_content> ... </main_content>
<footer> ... </footer>
</wrapper>
</body>
The header and footer are constant height, but the main_content
is dynamic.
I have main_content
set as flex:1
to automatically push the footer to the bottom of the window, when the content is short.
body {
padding: 0px;
margin: 0px;
}
#wrapper {
width: 100%;
min-height: 100vh;
padding: 0px;
margin: 0px;
display: flex;
flex-direction: column;
position: relative;
}
#header {
width: 100%;
height: 60px;
margin: 0px;
padding: 0px;
}
#main_content {
width: 100%;
flex: 1;
margin: 0px;
padding: 50px;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
#footer {
width: 100%;
height: 350px;
margin: 0px;
padding: 0px;
}
And for the most part, it all works exactly like you'd expect it to. A normally-behaving website layout.
The Problem
The issue I've encountered occurs in Safari, where new tabs are placed at the bottom of the nav-bar, and consume some of the page height (opposed to something like Chrome, where the tabs do not affect the height of the contents). Also, the issue only presents itself when the content is short, and so the footer
is exactly flush to the bottom of the window.
The Setup
When the page is loaded, with one or more tabs, it looks just fine:
As you can see (hopefully...), there are two tabs open at the top of the image. The contents of the page completely fill the viewport. Just as planned!
Reproducing
But then if you close all other tabs:
The tabs are gone (they only appear if more than one), BUT there is also a suspiciously tab-sized gap at the bottom of the page (white), where the page has failed to resize to fill the viewport.
If I resize the window, it immediately snaps back to filling the area. If I open the inspector and change any CSS property, it immediately snaps back to filling the area. But short of doing one of those things, I can't find a combination of CSS rules to prevent this from happening.
I've tried various combinations of position:absolute;
with all four sides set to zero. Also position:fixed;
with the same zeroes. No dice.
Any thoughts?
I'll keep playing around in the interim.
Additional
When I "Inspect Element" on the white gap at the bottom, the element selected is the top-level html
tag. The body
tag, and all its contents, end at the bottom of the footer.
Additional Additional
The problem occurs regardless of whether you load the page with tabs, and then close them, or load the page with no tabs, then open one or more, then close them all.