title: How do I make CSS grid stack on mobile?
body: <p>I have a CSS grid that has grid template columns set to <code>grid-template-columns: repeat(auto-fit, minmax(225px, 1fr))</code></p>
  
  <p>When I check the responsiveness of the site for mobile, the grid elements just get smaller and don't stack. I am trying to get them to stack into a 1fr column on mobile. I have tried using a media query to set the grid template columns to 1fr at a break-point and that didn't work.</p>
  
  <p>Here is a link to a CodePen of what I have <a href="https://codepen.io/Swildman/pen/ZEzqvXK" rel="noreferrer">https://codepen.io/Swildman/pen/ZEzqvXK</a></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>/* variables for colors */
  
  :root {
    --highlight-color: #ff7264;
    --white-color: #fff;
    --text-color: #7f7f7f;
    --dark-bg-color: #2e2e2e;
    --light-bg-color: #fff;
    --gray-bg-color: #666;
  }
  
  * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }
  
  
  /* services section */
  
  .services-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(225px, 1fr));
    grid-template-rows: repeat(3, 200px);
    grid-gap: 5px;
    margin: 5px;
  }
  
  .cell {
    background: var(--highlight-color);
    text-align: center;
    color: var(--white-color);
    padding: 10px;
  }
  
  .cell h3 {
    font-size: 20px;
  }
  
  .cell p {
    line-height: 1.4em;
  }
  
  .cell-1 {
    grid-column: 1/3;
    grid-row: 1/3;
    padding: 10px;
  }
  
  .cell-1 p,
  .cell-4 p {
    font-size: 20px;
    line-height: 1.4em;
  }
  
  .cell-1 h3,
  .cell-4 h3 {
    font-size: 30px;
  }
  
  .cell-1:hover {
    background-image: url("https://picsum.photos/460");
  }
  
  .cell-1:hover p,
  .cell-1:hover h3 {
    opacity: 0;
    transition: 1000ms;
  }
  
  .cell-2 {
    background-image: url("https://picsum.photos/225");
  }
  
  .cell-2 h3,
  .cell-2 p {
    opacity: 0;
  }
  
  .cell-2:hover {
    background: var(--highlight-color);
  }
  
  .cell-2:hover h3,
  .cell-2:hover p {
    opacity: 1;
    transition: 1000ms;
  }
  
  .cell-3 {
    background-image: url("https://picsum.photos/225");
  }
  
  .cell-3 h3,
  .cell-3 p {
    opacity: 0;
  }
  
  .cell-3:hover {
    background: var(--highlight-color);
  }
  
  .cell-3:hover h3,
  .cell-3:hover p {
    opacity: 1;
    transition: 1000ms
  }
  
  .cell-4 {
    grid-column: 3/5;
    grid-row: 2/4;
    padding: 10px;
  }
  
  .cell-4:hover {
    background-image: url("https://picsum.photos/460");
    background-repeat: no-repeat;
    background-size: cover;
  }
  
  .cell-4:hover p,
  .cell-4:hover h3 {
    opacity: 0;
    transition: 1000ms;
  }
  
  .cell-5 {
    background-image: url("https://picsum.photos/225");
  }
  
  .cell-5 h3,
  .cell-5 p {
    opacity: 0;
  }
  
  .cell-5:hover {
    background: var(--highlight-color);
  }
  
  .cell-5:hover h3,
  .cell-5:hover p {
    opacity: 1;
    transition: 1000ms;
  }
  
  .cell-6 {
    background-image: url("https://picsum.photos/225");
  }
  
  .cell-6 p,
  .cell-6 h3 {
    opacity: 0;
  }
  
  .cell-6:hover {
    background: var(--highlight-color);
  }
  
  .cell-6:hover p,
  .cell-6:hover h3 {
    opacity: 1;
    transition: 1000ms;
  }
  
  #services-section {
    text-align: center;
    margin-top: 30px;
    max-width: 900px;
    margin: 30px auto;
  }
  
  .services-title {
    font-size: 2em;
    text-shadow: 1px 1px var(--text-color);
    color: var(--highlight-color);
  }
  
  @media screen and (max-width: 768px) {
    grid-template-columns: 1fr;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;section id="services-section"&gt;
    &lt;h2 class="services-title"&gt;Services&lt;/h2&gt;
    &lt;div class="services-container"&gt;
      &lt;div class="cell cell-1"&gt;
        &lt;h3&gt;Creative Web Design Services&lt;/h3&gt;
        &lt;p&gt;Our web design services will greatly enhance your business’s presence on the Internet. Our designers mix a potent combination of brand strategy with a generous splash of creative juices and blend in the latest trends in Website UX and UI design.
          Since 2019, S&amp;E has designed and built over 25 Websites from e-commerce, b2c, b2b, non-profit, to social networks. We even create custom web applications.&lt;/p&gt;
      &lt;/div&gt;
      &lt;div class="cell cell-2"&gt;
        &lt;h3&gt;Digital Marketing&lt;/h3&gt;
        &lt;p&gt;Our digital marketing services are driven not only by passion, but also a driving desire to deliver exceptional sales conversions.&lt;/p&gt;
      &lt;/div&gt;
      &lt;div class="cell cell-3"&gt;
        &lt;h3&gt;App Development&lt;/h3&gt;
        &lt;p&gt;Our app development services are sought after from venture capital start-ups to fortune 100 companies.&lt;/p&gt;
      &lt;/div&gt;
      &lt;div class="cell cell-4"&gt;
        &lt;h3&gt;Website Maintenance&lt;/h3&gt;
        &lt;p&gt;Extend your Website’s Lifespan&lt;/p&gt;
        &lt;p&gt;By subscribing into a website maintenance plan with S&amp;E, we can help your website keep up with the ever-changing and evolving industry.&lt;/p&gt;
        &lt;p&gt;S&amp;E is one of the leading website maintenance agencies. Our web maintenance packages cover everything that your website may need – from simple content updates to extensive design updates.&lt;/p&gt;
      &lt;/div&gt;
      &lt;div class="cell cell-5"&gt;
        &lt;h3&gt;Web Development&lt;/h3&gt;
        &lt;p&gt;If you’re looking for custom Internet applications or complex web development solutions, you’ve come to the right place.&lt;/p&gt;
      &lt;/div&gt;
      &lt;div class="cell cell-6"&gt;
        &lt;h3&gt;Branding&lt;/h3&gt;
        &lt;p&gt;Branding has never been more expansive, adventurous and agile than it is today&lt;/p&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/section&gt;</code></pre>
  </div>
  </div>
  </p>