I'm wanting to fit the entire UI on the screen onLoad but my footer is not fixing to the bottom of the view on mobile.
On a desktop web browser, it works perfectly. When I view this on a mobile web browser, the footer is further down the page which makes the page scrollable. It should not scroll, instead, it should fit perfectly inside the viewport.
I've made sure to use the correct meta viewport tag. Included prefixes where I use flexbox. I tried using relative positioning but still not getting the results I want.
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
html,
body {
font-family: 'Roboto', sans-serif;
}
.container {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
height: 100%;
min-height: 100vh;
flex-direction: column;
max-width: 420px;
margin: 0 auto;
padding: 1rem 1rem 0 1rem;
}
header {
margin: 2rem 0;
}
main {
-webkit-box-flex: 1;
-moz-flex: 1;
-ms-flex: 1;
-webkit-flex: 1;
flex: 1;
}
footer .btn-group {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
margin-bottom: 1rem;
margin-top: 0.5rem;
}
<head>
<meta charset="UTF-8">
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<header>
<h1 class="title">Title</h1>
</header>
<main>
<div class="list">
<input type="text">
<input type="text">
</div>
</main>
<footer>
<div class="btn-group">
<button class="btn-refresh">
Refresh
</button>
<button class="btn-add">
Add New
</button>
</div>
<button class="btn">Main Action</button>
</footer>
</div>
</body>
On mobile, I'd expect that the footer is fixed to the bottom of the browser viewport, however, the button group is a bit past and a user would need to scroll to see the full group of buttons.
When looking at my codepen version, this works fine. However, when I copy&paste the code to my server the footer does not stay at the bottom.
Is there anything that I am missing?