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:20% auto 10%;
grid-template-rows:calc(30vh - 20px) 50vh calc(20vh - 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: 1/4;
border-radius: 10px;
}
.class2{
display: flex;
align-items:center;
justify-content: center;
background: var(--bg);
text-align: center;
grid-column:1/2;
grid-row: 2/4;
border-radius: 10px;
}
.class3{
display: flex;
align-items:center;
justify-content: center;
background: var(--bg);
text-align: center;
grid-column:2/3;
border-radius: 10px;
}
.class4{
display: flex;
align-items:center;
justify-content: center;
background: var(--bg);
text-align: center;
border-radius: 10px;
}
.class5{
display: flex;
align-items:center;
justify-content: center;
flex-direction: column;
background: var(--bg);
text-align: center;
grid-column:2/4;
border-radius: 10px;
}
@media only screen and (max-width: 860px){
.grid-container{
grid-template-columns: auto auto;
grid-template-rows:calc(20vh - 20px) 60vh calc(20vh - 20px);
}
.class2{
grid-column: 1/2;
grid-row: 2/4;
}
.class3{
grid-column: 2/4;
}
.class4{
grid-column: 2/4;
}
.class5{
grid-column: 1/4;
}
}
@media only screen and (max-width: 600px){
.grid-container{
grid-template-columns: auto;
grid-template-rows:20vh 10vh 40vh 10vh 20vh;
}
.class1{
grid-column: 1/4;
}
.class2{
grid-column: 1/4;
grid-row: 2/3;
}
.class3{
grid-column: 1/4;
}
.class4{
grid-column: 1/4;
}
.class5{
grid-column: 1/4;
}
}
.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.
إرسال تعليق
Thank you
Learning robo team