responsive grid
1:-
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
*{
margin: 0px;
padding: 0px;
box-sizing: border-box;
}
.container{
/* width: 500px; */
height: 500px;
border: 1px solid red;
display: grid;
/* grid-template-rows: 100px 200px;
grid-auto-rows: 200px; */
/* column-gap: 1em;
row-gap: 1em; */
gap: 1em;
}
.item1{
/* width: 100px; */
/* height: 100px; */
background-color: blue;
/* grid-column-start: 1;
grid-column-end: 4; */
}
.item2{
/* width: 100px; */
/* height: 100px; */
background-color: yellow;
}
.item3{
/* width: 100px; */
/* height: 100px; */
background-color: cyan;
}
.item4{
/* width: 100px; */
/* height: 100px; */
background-color: green;
}
.item5{
/* width: 100px; */
/* height: 100px; */
background-color: rgb(128, 0, 11);
}
.item6{
/* width: 100px; */
/* height: 100px; */
background-color:red;
}
@media screen and (min-width:40em) {
.container{
grid-template-columns:repeat(3,1fr);
}
.item1{
grid-column: 1/4;
}
.item2{
grid-column: 1/4;
}
.item3{
grid-column: 1/3;
}
.item4{
grid-column: 1/3;
}
.item5{
grid-row: 3/5;
grid-column: 3/4;
}
.item6{
grid-column: 1/4;
}
}
</style>
</head>
<body>
<div class="container">
<div class="item1">1</div>
<div class="item2">2</div>
<div class="item3">3</div>
<div class="item4">4</div>
<div class="item5">5</div>
<div class="item6">6</div>
</div>
</body>
</html>
2:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
*{
margin: 0px;
padding: 0px;
box-sizing: border-box;
}
.container{
/* width: 500px; */
height: 500px;
border: 1px solid red;
display: grid;
grid-template-columns:repeat(3,1fr);
grid-auto-rows: minmax(100px,auto);
grid-template-areas:
"header header header "
"nav nav nav "
"aside aside asideright"
"asidedown asidedown asideright"
"footer footer footer"
;
/* grid-template-rows: 100px 200px;
grid-auto-rows: 200px; */
/* column-gap: 1em;
row-gap: 1em; */
gap: 1em;
}
.item1{
/* width: 100px; */
/* height: 100px; */
background-color: blue;
grid-area: header;
/* grid-column-start: 1;
grid-column-end: 4; */
}
.item2{
/* width: 100px; */
/* height: 100px; */
background-color: yellow;
grid-area: nav;
}
.item3{
grid-area: aside;
/* width: 100px; */
/* height: 100px; */
background-color: cyan;
}
.item4{
grid-area: asidedown;
/* width: 100px; */
/* height: 100px; */
background-color: green;
}
.item5{
grid-area: asideright;
/* width: 100px; */
/* height: 100px; */
background-color: rgb(128, 0, 11);
}
.item6{
grid-area: footer;
/* width: 100px; */
/* height: 100px; */
background-color:red;
}
@media screen and (max-width:40em) {
.container{
grid-template-areas:
"header header header "
"nav nav nav "
"aside aside aside"
"asidedown asidedown asidedown"
"asideright asideright asideright"
"footer footer footer"
;
}
}
/* @media screen and (min-width:40em) {
.container{
grid-template-columns:repeat(3,1fr);
}
.item1{
grid-column: 1/4;
}
.item2{
grid-column: 1/4;
}
.item3{
grid-column: 1/3;
}
.item4{
grid-column: 1/3;
}
.item5{
grid-row: 3/5;
grid-column: 3/4;
}
.item6{
grid-column: 1/4;
}
} */
</style>
</head>
<body>
<div class="container">
<div class="item1">1</div>
<div class="item2">2</div>
<div class="item3">3</div>
<div class="item4">4</div>
<div class="item5">5</div>
<div class="item6">6</div>
</div>
</body>
</html>
Comments
Post a Comment