I've recently started using CSS grid layout for a web application. I found a nice example at https://duwp7.csb.app/ that does what I want when on a desktop browser. I really like that I don't need to use javascript to pad the main content to make room for the header and footer.
However when I use a mobile browser I find that the footer is below the bottom of the screen and I need to scroll to get to it. Is it possible to use a CSS grid layout footer on a mobile device? Or do I need to stick with my CSS + javascript solution?
The CSS that I'm using is below. "fll-sw-ui-body" is used for the container element.
.fll-sw-ui-body {
/* make sure that only the content scrolls */
overflow: hidden;
/* use full viewport for elements, also avoids pushing elements off the screen when using full height */
margin: 0;
height: 100vh;
display: grid;
grid-template-columns: 1fr;
grid-template-rows: auto 1fr auto;
grid-template-areas: 'header' 'main' 'footer';
}
.fll-sw-ui-body>header, .fll-sw-ui-body>footer {
text-shadow: 0 1px 0 #eee;
background: #333;
z-index: 1000;
background-color: #e9e9e9;
border-color: #ddd;
}
.fll-sw-ui-body>header {
grid-area: header;
}
.fll-sw-ui-body>main {
grid-area: main;
overflow: auto;
background-color: #f9f9f9;
}
.fll-sw-ui-body>footer {
grid-area: footer;
}
HTML code
<body class='fll-sw-ui-body'>
<header>
header content ...
</header>
<main>
main content ...
</main>
<footer>
footer content ...
</footer>
</body>