how to make css grid responsive code example

Example 1: responsive css grid

@supports (display: grid) {
  main { 
    max-width: 10000px;
    margin: 0;
  }
  .grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 2fr));
    grid-gap: 1rem;
  }
}

Example 2: css grid example

<!-- HTML code -->
<div class="wrapper">
  <div class="box">A</div><div class="box">B</div><div class="box">C</div>
  <div class="box">D</div><div class="box">E</div><div class="box">F</div>
</div>

<!-- Css code -->
<style>
.wrapper {
  display: grid;
  grid-template-columns: 100px 100px 100px;
  grid-gap: 10px;
  background-color: #fff;
  color: #444;
}
.box {
  background-color: #444;
  color: #fff;
  border-radius: 5px;
  padding: 20px;
  font-size: 150%;
}
</style>

Example 3: css grid responsive

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

Tags:

Html Example