title: CSS Grid content to stay in the grid area and not to flow out
body: <p>Is there a way for the grid areas to automatically adjust to the size of the content in them. </p>
  
  <p>Right now I have used:<br>
  grid-auto-rows: min-content;</p>
  
  <p>And </p>
  
  <p>grid-auto-columns: min-content;</p>
  
  <p>and thought that should fix the problem. </p>
  
  <p>The image below shows how the content is not contained in the grid area.</p>
  
  <p><a href="https://i.stack.imgur.com/gbTSI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gbTSI.png" alt="enter image description here"></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>.container {
          display: grid;
          grid-gap: 20px;
          grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
          grid-auto-rows: min-content;
          grid-auto-columns: min-content;
        }
        
        
        
        :root {
    --yellow: #ffc600;
    --black: #272727;
  }
  
  html {
    box-sizing: border-box;
    font-size: 10px;
    color: var(--black);
  
  }
  
  *,
  *:before,
  *:after {
    box-sizing: inherit;
  }
  
  
  
  .item {
    display: grid;
    justify-content: center;
    align-items: center;
    border: 5px solid rgba(0, 0, 0, 0.03);
    border-radius: 3px;
    font-size: 35px;
    background-color: var(--yellow); 
  }
  
  .item p {
    margin: 0 0 5px 0;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="container"&gt;
        &lt;div class="item item1"&gt;1kajhdkha&lt;/div&gt;
        &lt;div class="item item2"&gt;2aksdakj&lt;/div&gt;
        &lt;div class="item item3"&gt;as,jhdahfjhs,h3&lt;/div&gt;
        &lt;div class="item item4"&gt;4akshdasd&lt;/div&gt;
      &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>