title: CSS - How to make a square/squares fit and resize inside a div when added more squares?
body: <p>I am making a loyalty card in html and css, and i have an option that the user can select the number of squares that are inside the div.</p>
  <p>My problem is when the user select more that a specific number,the squares get out of the div instead of resize and fit the div.</p>
  <p>Can anyone help me with that?</p>
  <p>Here is the code:</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>#card{
    position: relative;
    height: 250px;
    margin: 15px;
    width: 400px
  }
  
  #squares{
    position: absolute;
    bottom: 20px;
   width: 100%;
    z-index: 10;
    text-align: center;
   margin: 0 auto;
    top: 10px;
  }
  
  .square{
    height: 50px;
    width: 50px;
    background-color: white;
    border: 1px solid #1e2023;
    margin: 5px;
   display: inline-block
  }
  
  #cardDescription{
    position: absolute;
    z-index: 11;
    width: 100%;
    background-color: white;
    text-align: center;
    height: 50px;
    bottom: 20px;
  }
  
  #userPhoto{
   position: absolute;
    width: 100%;
    height: 100%;
    background-color: black;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code> &lt;div id="card"&gt;
        &lt;img id="userPhoto"/&gt;
        &lt;div id="squares"&gt;
          &lt;span class="square"&gt;&lt;/span&gt;
          &lt;span class="square"&gt;&lt;/span&gt;
          &lt;span class="square"&gt;&lt;/span&gt;
          &lt;span class="square"&gt;&lt;/span&gt;
          &lt;span class="square"&gt;&lt;/span&gt;
          &lt;span class="square"&gt;&lt;/span&gt;
          &lt;span class="square"&gt;&lt;/span&gt;
          &lt;span class="square"&gt;&lt;/span&gt;
          &lt;span class="square"&gt;&lt;/span&gt;
          &lt;span class="square"&gt;&lt;/span&gt;
          &lt;span class="square"&gt;&lt;/span&gt;
          &lt;span class="square"&gt;&lt;/span&gt;
          &lt;span class="square"&gt;&lt;/span&gt;
        &lt;/div&gt;
        &lt;div id="cardDescription"&gt;
          &lt;h1&gt;Test text&lt;/h1&gt;
        &lt;/div&gt;
      &lt;/div&gt;
  
     </code></pre>
  </div>
  </div>
  </p>
  <p>If anyone can help me i would appreciated</p>