educative.io

Educative

Grid areas responsive hide

<!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>
  </head>

  <style>
    /*===========
 basic reset
===========*/
    body {
      margin: 0;
      padding: 0;
    }

    /*=============================
  default grid set up -> mobile first
===============================*/
    body {
      display: grid;
      min-height: 100vh;
      min-width: 100%;
      grid-template-rows: 1fr 90px;
      grid-template-columns: 1fr;
      grid-template-areas:
        "content"
        "footer";
    }

    .main {
      background-color: #2c3e50;
      grid-area: content;
    }

    .footer {
      background-color: #c0392b;
      grid-area: footer;
    }

    .aside {
      background-color: #7f8c8d;
      grid-area: sidebar;
    }

    /*=============================
  larger screens
===============================*/

    @media only screen and (min-width: 600px) {
      body {
        grid-template-columns: 40px 1fr;
        grid-template-areas:
          "sidebar  content"
          "footer  footer";
      }
    }
  </style>
  <body class="grid-container">
    <div class="aside">aside</div>
    <div class="main">main</div>
    <div class="footer">footer</div>
  </body>
</html>

Spouse, you have that code. The aside element will not be hidden just because you don’t add it in the grid-template-areas, because it has content. How can we hide things correctly?