Grid auto fit property in css

technical talkiess
0

 Grid auto fit property:- 

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Auto fit in grid</title>

</head>

<style>

    .container{

        display: grid;

        /* isse apko desire column milte hai ... aur aap usko adjust kar sakte hai  */

        /* grid-template-columns: 1fr 1fr 1fr; */

        /* agar apko isko agar responsive bana na hai to aap simply auto fit property ka use kar sakte hai... */

        /* isme sabse pahile min atta hai aur last me max atta hai  */

        grid-template-columns: repeat(auto-fit,minmax(300px,1fr));

    }

    .box{

        background-color: blanchedalmond;

        padding: 23px;

        margin: 12px;

        border: 2px solid black;

    }

</style>

<body>

    <div class="container">

        <div class="box">item-1</div>

        <div class="box">item-2</div>

        <div class="box">item-3</div>

        <div class="box">item-4</div>

        <div class="box">item-5</div>

        <div class="box">item-6</div>

        <div class="box">item-7</div>

        <div class="box">item-8</div>

        <div class="box">item-9</div>

        <div class="box">item-10</div>

    </div>

</body>

</html>


Post a Comment

0Comments

Thanks you for commenting your questions. I will see question and respond you.

Post a Comment (0)