jsartisan / frontend-challenges

FrontendChallenges is a collection of frontend interview questions and answers. It is designed to help you prepare for frontend interviews. It's free and open source.
https://frontend-challenges.com
21 stars 4 forks source link

40 - Layout 1 #42

Open jsartisan opened 4 months ago

jsartisan commented 4 months ago

styles.css

.container {
  display: grid;
  gap: 0.5rem;
}

.item {
  background: #e1e1e1;
  height: 100px;
}

@media (width >= 400px) {
  .container {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (width >= 600px) {
  .container {
    grid-template-columns: repeat(4, 1fr);
  }

  .item {
    grid-column: span 2;
  }

  .item:nth-child(1), .item:nth-child(6) {
    grid-column: span 4;
  }
}

@media (width >= 800px) {
  .item {
    grid-column: span 1;
  }

  .item:nth-child(1), .item:nth-child(6) {
    grid-column: span 2;
  }
}