How to create a Responsive Grid Layout with HTML and CSS.[Source Code]
To make this website, you would like to make two files: an HTML file, a CSS file. First, create an HTML file with the name of index.html and remember, you have to create a file with a .html extension.
@import url('https://fonts.googleapis.com/css2?family=Righteous&display=swap');
:root{
--bg:#ffffff;
}
body{
margin:0%;
font-family: 'Righteous', cursive;
}
.grid-container{
display:grid;
grid-template-columns:15% calc(32.5% - 15px) calc(32.5% - 15px) 20%;
grid-template-rows:calc(20vh - 20px) 50vh calc(30vh - 20px);
gap:10px;
background: #00ACEF;
background: -webkit-linear-gradient(to right, #00ACEF, #3F62D6);
background: linear-gradient(to right, #00ACEF, #3F62D6);
padding:10px;
}
.class1{
display: flex;
align-items:center;
justify-content: center;
background: var(--bg);
text-align: center;
grid-column: 2/5;
border-radius: 10px;
}
.class2{
display: flex;
align-items:center;
justify-content: center;
background: var(--bg);
text-align: center;
grid-row: 1/4;
grid-column: 1/2;
border-radius: 10px;
}
.class3{
display: flex;
align-items:center;
justify-content: center;
background: var(--bg);
text-align: center;
grid-column:2/4;
border-radius: 10px;
}
.class4{
display: flex;
align-items:center;
justify-content: center;
background: var(--bg);
text-align: center;
grid-column:4/5;
grid-row:2/4;
border-radius: 10px;
}
.class5{
display: flex;
align-items:center;
justify-content: center;
flex-direction: column;
background: var(--bg);
text-align: center;
grid-column:2/3;
border-radius: 10px;
}
.class6{
display: flex;
align-items:center;
justify-content: center;
flex-direction: column;
background: var(--bg);
text-align: center;
grid-column:3/4;
border-radius: 10px;
}
@media only screen and (max-width: 860px){
.grid-container{
grid-template-columns: 15% 28% 28% 25%;
grid-template-rows:calc(20vh - 20px) 60vh calc(20vh - 20px);
}
}
@media only screen and (max-width: 600px){
.grid-container{
grid-template-columns: auto;
grid-template-rows:15vh 10vh 35vh 10vh 15vh 15vh;
}
.class1{
grid-column: 1/4;
border-radius: 10px;
}
.class2{
grid-column: 1/4;
grid-row:2/3;
border-radius: 10px;
}
.class3{
grid-column: 1/4;
border-radius: 10px;
}
.class4{
grid-column: 1/4;
grid-row:4/5;
border-radius: 10px;
}
.class5{
grid-column: 1/4;
border-radius: 10px;
}
.class6{
grid-column: 1/4;
border-radius: 10px;
}
}
.credit a{
text-decoration:none;
color: #000;
font-weight: 600;
}
.credit {
color:#000;
}
Thank you for reading our blog. If you face any problem in Creating a Responsive CSS Grid Layout with HTML and CSS., then contact us or comment to us. We’ll try to provide a solution to your problem as soon as possible.
Explore
Press The Key ' p ' and say ' read article ' our voice assistant read our article.
In Our older post it doesnot work we working on that.
In Our older post it doesnot work we working on that.
Post a Comment
Thank you
Learning robo team