Recently, I've been working on designing a website layout using CSS-Grid. Everything seems to be functioning properly and adapting well to different screen sizes until I encountered an issue with scroll bars appearing at very small resolutions. This causes the css-grid to stop stretching over the entire page height, leaving a blank white space at the bottom.
If you want to visualize this problem, try running the provided snippet in a low-height window. In addition, I have included screenshots of how it appears on my browser for reference.
How it looks at normal height:
What happens when the height is reduced:
I attempted adjusting the overflow
and min-height
properties but was unable to resolve the issue completely. While not critical, I am curious to understand why it occurs. Thank you!
body, html{
height: 100vh;
min-height: 100vh;
min-width: 300px;
margin: 0;
padding: 0;
}
.grid-container-1{
height: 100vh;
min-height: 100vh;
min-width: 300px;
margin: 0;
padding: 0;
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr;
grid-template-rows: 8% 70% auto 8% ;
grid-template-areas:
"header1 header1 header1 header1"
"Cover Cover Cover Cover"
"Project Project Project Project"
"Footer Footer Footer Footer"
}
.header1{
grid-area: header1;
}
.cover{
grid-area: Cover;
}
.Project{
grid-area: Project;
}
.Footer{
grid-area: Footer;
}
.zone {
cursor:pointer;
color:#FFF;
font-size:2em;
border-radius:4px;
border:1px solid #bbb;
transition: all 0.3s linear;
}
.zone:hover {
-webkit-box-shadow:rgba(0,0,0,0.8) 0px 5px 15px, inset rgba(0,0,0,0.15) 0px -10px 20px;
-moz-box-shadow:rgba(0,0,0,0.8) 0px 5px 15px, inset rgba(0,0,0,0.15) 0px -10px 20px;
-o-box-shadow:rgba(0,0,0,0.8) 0px 5px 15px, inset rgba(0,0,0,0.15) 0px -10px 20px;
box-shadow:rgba(0,0,0,0.8) 0px 5px 15px, inset rgba(0,0,0,0.15) 0px -10px 20px;
}
/* Source: https://paulund.co.uk/how-to-create-shiny-css-buttons */
/* Various Color Background Styles */
.green{
background: #56B870; /* Old browsers */
background: -moz-linear-gradient(top, #56B870 0%, #a5c956 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#56B870), color-stop(100%,#a5c956)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #56B870 0%,#a5c956 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #56B870 0%,#a5c956 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #56B870 0%,#a5c956 100%); /* IE10+ */
background: linear-gradient(top, #56B870 0%,#a5c956 100%); /* W3C */
}
.red{
background: #C655BE;
...
}
.yellow{
background: #F3AAAA;
...
}
.blue{
background: #7abcff;
...
}
<!DOCTYPE html>
<html>
<head>
<title>CSS Layout</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="grid-container-1">
<div class="header1 zone green">
Header
</div>
<div class="cover zone red">
Cover
</div>
<div class="Project zone blue">
Projects
</div>
<div class="Footer zone yellow">
Footer
</div>
</div>
</body>
</html>