title: Centering a div block without the width
body: <p>I have a problem when I try to center the div block "products" because I don't know in advance the div width.  Anybody have a solution?</p>
  
  <p>Update: The problem I have is I don't know how many products I'll display, I can have 1, 2 or 3 products, I can center them if it was a fixed number as I'd know the width of the parent div, I just don't know how to do it when the content is dynamic.</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>.product_container {
    text-align: center;
    height: 150px;
  }
  
  .products {
    height: 140px;
    text-align: center;
    margin: 0 auto;
    clear: ccc both; 
  }
  .price {
    margin: 6px 2px;
    width: 137px;
    color: #666;
    font-size: 14pt;
    font-style: normal;
    border: 1px solid #CCC;
    background-color: #EFEFEF;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="product_container"&gt;
    &lt;div class="products" id="products"&gt;
      &lt;div id="product_15"&gt;
        &lt;img src="/images/ecommerce/card_default.png"&gt;
        &lt;div class="price"&gt;R$ 0,01&lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div id="product_15"&gt;
        &lt;img src="/images/ecommerce/card_default.png"&gt;
        &lt;div class="price"&gt;R$ 0,01&lt;/div&gt;
      &lt;/div&gt;   
  
      &lt;div id="product_15"&gt;
        &lt;img src="/images/ecommerce/card_default.png"&gt;
        &lt;div class="price"&gt;R$ 0,01&lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>