Grids are commonly used throughout designs in order to space content out in an appropiate style. Grids allow the design to maintain it's shape and enhance the layout of the page. There are various grids that can be used ranging from 1 large grid spread across the page to as many as you want. Most websites tend to use 12-unit grids.
2 Column Grid with Padding
HTML and CSS Code
HTML Code
CSS Code
.grid-container2 {
display: grid;
grid-template-columns: 49.5% 49.5%;
background-color: #333333;
padding: 10px;
column-gap: 1%;
width: 100%;
}
.grid-item2 {
background-color: white;
border: 1px solid black;
padding: 20px;
font-size: 20px;
text-align: center;
}
3 Column Grid with Padding
Column 1
Column 2
Column 3
HTML and CSS Code
HTML Code
Column 1
Column 2
Column 3
CSS Code
.grid-container3 {
display: grid;
grid-template-columns: 32.66% 32.66% 32.66%;
background-color: #333333;
padding: 10px;
column-gap: 1%;
width: 100%;
}
.grid-item3 {
background-color: white;
border: 1px solid black;
padding: 20px;
font-size: 20px;
text-align: center;
}
4 Column Grid with Padding
Column 1
Column 2
Column 3
Column 4
HTML and CSS Code
HTML Code
Column 1
Column 2
Column 3
Column 4
CSS Code
.grid-container4 {
display: grid;
grid-template-columns: 24.25% 24.25% 24.25% 24.25%;
background-color: #333333;
padding: 10px;
column-gap: 1%;
width: 100%;
}
.grid-item4 {
background-color: white;
border: 1px solid black;
padding: 20px;
font-size: 20px;
text-align: center;
}