Our mobile web application has sticky bottom navigation like the one you often find in iOS applications, and after Safari 10.3 release on landscape only it is p
There is another way of creating a fixed element at the bottom of the page:
Set the element (or whatever wraps your header, content and footer) to
display: flex; height: 100vh
. Then you take the footer and set it to margin-top: auto
.
HTML:
CSS:
html {
height: 100%;
}
body {
height: 100%;
display: flex;
flex-direction: column;
}
main {
flex: 1;
}
A different solution with the same markup would be to use CSS Grid:
html {
height: 100%;
}
body {
height: 100%;
display: grid;
grid-template-rows: auto 1fr auto;
}
In order to get the best of both worlds you can wrap the CSS Grid styles in an @supports(display: grid){}
wrapper. If Grid is supported the browser will take that and otherwise will fallback to Flexbox.
The best thing using this technique is that you won't run into overlapping contents, into zooming-issues and it is fully responsive from the get-go.
There is an article on CSS Tricks about the subject: https://css-tricks.com/couple-takes-sticky-footer/