grid-template-rows: repeat (2, 1fr)
is not required. Rows are arranged automatically.
If your container has a fixed size, use px
size instead of vh
. You can also use the calc
function.
* { box-sizing: border-box;
}
html,body {
height: 100%;
margin: 0;
}
.footer {
height: 10vh;
background-color: #eee;
text-align: center;
}
.wrapper {
display: grid;
grid-template-columns: repeat(6, 1fr);
grid-gap: 1px;
justify-content: center;
height: 90vh;
}
.box {
background-color: #444;
color: #fff;
padding: 10px;
font-size: 12px;
}
<section class="container">
<div class="wrapper">
<div class="box a">A</div><div class="box b">B</div><div class="box c">C</div><div class="box d">D</div>
<div class="box e">E</div><div class="box f">F</div><div class="box a">A</div><div class="box b">B</div>
<div class="box c">C</div><div class="box d">D</div><div class="box e">E</div><div class="box f">F</div>
</div>
</section>
<footer class="footer">
footer
</footer>
If your container has a fixed size, use a px
size
Or use Flex:
* { box-sizing: border-box;
}
html,body {
height: 100%;
margin: 0;
}
.footer {
height: 10vh;
background-color: #eee;
text-align: center;
}
.wrapper {
display: flex;
flex-wrap: wrap;
align-items: stretch;
height:90vh;
}
.wrapper > div {
width: 16.666%;
text-align: center;
font-size: 12px;
line-height: 6;
border: 1px solid;
background-color: #444;
}
<section class="container">
<div class="wrapper">
<div class="box a">A</div><div class="box b">B</div><div class="box c">C</div><div class="box d">D</div>
<div class="box e">E</div><div class="box f">F</div><div class="box a">A</div><div class="box b">B</div>
<div class="box c">C</div><div class="box d">D</div><div class="box e">E</div><div class="box f">F</div>
</div>
</section>
<footer class="footer">
footer
</footer>
No footer:
* { box-sizing: border-box;}
html,body {
height: 100%;
margin: 0;
}
.container {
position: relative;
min-height:100%;
}
.wrapper {
display: flex;
flex-wrap: wrap;
height:100%;
margin: 0 auto;
max-height:100%;
position:absolute;
top: 0; bottom: 0; left: 0; right: 0;
}
.wrapper > div {
width: 16.666%;
text-align: center;
font-size: 12px;
line-height: 6;
border: 1px solid;
background-color: #444;
}
<section class="container">
<div class="wrapper">
<div class="box a">A</div><div class="box b">B</div><div class="box c">C</div><div class="box d">D</div>
<div class="box e">E</div><div class="box f">F</div><div class="box a">A</div><div class="box b">B</div>
<div class="box c">C</div><div class="box d">D</div><div class="box e">E</div><div class="box f">F</div>
</div>
</section>
example 4: footer and header
* { box-sizing: border-box; }
html,body {
height: 100%;
margin: 0;
}
.footer {
height: 10vh;
background-color: #eee;
text-align: center;
font-size: 4vh;
}
.header {
height: 10vh;
background-color: #eee;
text-align: center;
font-size: 4vh;
}
.wrapper {
display: flex;
flex-wrap: wrap;
align-items: stretch;
height:80vh;
}
.wrapper > div {
width: 16.666%;
text-align: center;
border: 1px solid;
background-color: #444;
}
<div class="header">header</div>
<section class="container">
<div class="wrapper">
<div class="box a">A</div><div class="box b">B</div><div class="box c">C</div><div class="box d">D</div>
<div class="box e">E</div><div class="box f">F</div><div class="box a">A</div><div class="box b">B</div>
<div class="box c">C</div><div class="box d">D</div><div class="box e">E</div><div class="box f">F</div>
</div>
</section>
<footer class="footer">
footer
</footer>
**example 5: **
* { box-sizing: border-box;}
html,body { height: 100%; margin: 0;}
.footer {
height: 15vh;
background-color: #eee;
text-align: center;
}
.header {
height: 15vh;
background-color: #eee;
text-align: center;
}
.wrapper {
display: flex;
flex-wrap: wrap;
align-items: stretch;
height:70vh;
}
.wrapper > div {
width: 16.666%;
text-align: center;
font-size: 12px;
border: 1px solid;
background-color: #444;
}
<div class="header">header</div>
<div class="wrap">
<section class="container">
<div class="wrapper">
<div class="box a">A</div><div class="box b">B</div><div class="box c">C</div><div class="box d">D</div>
<div class="box e">E</div><div class="box f">F</div><div class="box a">A</div><div class="box b">B</div>
<div class="box c">C</div><div class="box d">D</div><div class="box e">E</div><div class="box f">F</div>
</div>
</section>
</div>
<div class="footer">
footer
</div>