title: How to make a div adapt to its content's width?
body: <p>this is my first question here, but I've read many Java answers which helped me a lot. I did some research before, but don't hesitate to tell me if I duplicated a question or am doing anything wrong.</p>
  
  <p>I'm trying to create a thumbnails gallery and I made a <a href="https://jsfiddle.net/b0os7917/" rel="nofollow noreferrer">jsfiddle here</a>.</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;body&gt;
    &lt;div id="main"&gt;
      &lt;div id="wrapper"&gt;
        &lt;div class="box"&gt;&lt;/div&gt;
        &lt;div class="box"&gt;&lt;/div&gt;
        &lt;div class="box"&gt;&lt;/div&gt;
        &lt;div class="box"&gt;&lt;/div&gt;
        &lt;div class="box"&gt;&lt;/div&gt;
        &lt;div class="box"&gt;&lt;/div&gt;
        &lt;div class="box"&gt;&lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p><strong>CSS</strong></p>
  
  <pre><code>#main {
    background-color: rgba(255, 105, 180, 0.5);
    height: 100vh;
    padding: 10px;
  }
  
  #wrapper {
    background-color: blue;
    display: inline-block;
    padding: 5px;
  }
  
  .box {
    display: inline-block;
    background-color: red;
    width: 200px;
    height: 200px;
    margin: 5px;
  }
  </code></pre>
  
  <p>I would like to center the red boxes in the main div, but not like <code>text-align: center;</code>, align the boxes left-to-right between them, and center the whole block. So I thought, why not make a wrapper div and center it ?
  This is where my problem is, I would like the blue wrapper to be no larger than its content, but it fills the main div.
  An answer <a href="https://stackoverflow.com/questions/450903/how-to-make-div-not-larger-than-its-contents">here</a> says <code>inline-block</code> should solve the issue but I can't figure out how.
  The whole thing surely can be made quite easily, so what am I missing ?</p>
  
  <p>If TLDR, I made some snapshots here : <a href="https://imgur.com/a/a2Fjg" rel="nofollow noreferrer">http://imgur.com/a/a2Fjg</a></p>
  
  <p>Thanks a lot !</p>