title: CSS: Override parent's inline style width to adjust to child width
body: <p>I usually set parent's  <code>.text-container</code>  display to inline-block to align the width with the child  <code>.text</code> . Here I have an additional problem: parents width is hardcoded as element.style. How do I override the inline style AND adjust to child width at the same time? I can only use CSS.</p>
  
  <p><a href="https://jsfiddle.net/xc7ybt31/" rel="nofollow noreferrer">https://jsfiddle.net/xc7ybt31/</a></p>
  
  <p>HTML</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> .text {
    display: inline;
  }
  .text-container {
    display: inline-block;
    float:left;
  }
  .main-container {
    display: inline-block;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="main-container"&gt;
    &lt;div class="text-container" style="width:100px"&gt;
      &lt;div class="text"&gt;
        text
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  
   </code></pre>
  </div>
  </div>
  </p>