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>
        *{
            margin0px;
            padding0px;
            box-sizingborder-box;
        }
        .container{
/* width: 500px; */
height500px;
border1px solid red;
displaygrid;

/* grid-template-rows: 100px 200px;
grid-auto-rows: 200px; */
/* column-gap: 1em;
row-gap: 1em; */
gap1em;
        }
        .item1{
            /* width: 100px; */
            /* height: 100px; */
            background-colorblue;
            /* grid-column-start: 1;
            grid-column-end: 4; */

        }
        
        .item2{
            /* width: 100px; */
            /* height: 100px; */
            background-coloryellow;
          
        }
        
        .item3{
            /* width: 100px; */
            /* height: 100px; */
            background-colorcyan;
         
        }
        .item4{
            /* width: 100px; */
            /* height: 100px; */
            background-colorgreen;
           
        }
        .item5{
            /* width: 100px; */
            /* height: 100px; */
            background-colorrgb(128011);
            
        }
        .item6{
            /* width: 100px; */
            /* height: 100px; */
            background-color:red;
           
        }
        @media screen and (min-width:40em) {
            .container{
                grid-template-columns:repeat(3,1fr);
                
            }
            .item1{
                grid-column1/4;
            }
            .item2{
                grid-column1/4;
            }
            .item3{
                grid-column1/3;
            }
            .item4{
                grid-column1/3;
            }
            .item5{
                grid-row3/5;
            grid-column3/4;
            }
            .item6{
                grid-column1/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>
        *{
            margin0px;
            padding0px;
            box-sizingborder-box;
        }
        .container{
/* width: 500px; */
height500px;
border1px solid red;
displaygrid;
grid-template-columns:repeat(3,1fr);
grid-auto-rowsminmax(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; */
gap1em;
        }
        .item1{
            /* width: 100px; */
            /* height: 100px; */
            background-colorblue;
            grid-area: header;
            /* grid-column-start: 1;
            grid-column-end: 4; */

        }
        
        .item2{
            /* width: 100px; */
            /* height: 100px; */
            background-coloryellow;
            grid-area: nav;
          
        }
        
        .item3{
            grid-area: aside;
            /* width: 100px; */
            /* height: 100px; */
            background-colorcyan;
         
        }
        .item4{
            grid-area: asidedown;
            /* width: 100px; */
            /* height: 100px; */
            background-colorgreen;
           
        }
        .item5{
            grid-area: asideright;
            /* width: 100px; */
            /* height: 100px; */
            background-colorrgb(128011);
            
        }
        .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

Popular posts from this blog

interview questions js[ Anurag Singh ProCodrr]

reactnative_creation