Using Media Queries to Create Responsive Layouts

I’m stuck at this challenge


<style>
  .item1 {
    background: LightSkyBlue;
    grid-area: header;
  }
  
  .item2 {
    background: LightSalmon;
    grid-area: advert;
  }
  
  .item3 {
    background: PaleTurquoise;
    grid-area: content;
  }
  
  .item4 {
    background: lightpink;
    grid-area: footer;
  }
  
  .container {
    font-size: 1.5em;
    min-height: 300px;
    width: 100%;
    background: LightGray;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 50px auto 1fr auto;
    grid-gap: 10px;
    grid-template-areas:
      "header"
      "advert"
      "content"
      "footer";
  }
  
  @media (min-width: 300px){
    .container{
      grid-template-columns: auto 1fr;
      grid-template-rows: auto 1fr auto;
      grid-template-areas:
        " header"
        "advert content advert"
        " footer";
    }
  }
  // Ive tried all I know but its not working at all
  @media (min-width: 400px){
    .container{
      /* change the code below this line */

      grid-template-areas:
        " header header"
        "advert content advert"
        "footer footer";
    
    /* change the code above this line */
    }
  }
</style>
  
<div class="container">
  <div class="item1">header</div>
  <div class="item2">advert</div>
  <div class="item3">content</div>
  <div class="item4">footer</div>
</div>

Link to the challenge:
https://learn.freecodecamp.org/responsive-web-design/css-grid/use-media-queries-to-create-responsive-layouts

     grid-template-areas:
        " header header"
        "advert content advert"
        "footer footer";

There’s just one unnecessary bit in the above code. You can probably guess which one.
Try the above code (your code) for the mid-width: 400px container in the min-width: 300px container and watch how the layout on the right changes.

1 Like

Remember it is a one or two column layout (not three).

1 Like

Thanks guys, I solved it.

1 Like