title: Stretch flex item with overflowing content to the full available width of its container
body: <p>I have a layout like this:</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;html&gt;
    &lt;head&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;div class="container"&gt;
      &lt;div class="left-container"&gt;
        SIDEBAR
      &lt;/div&gt;
      &lt;div class="right-container"&gt;
        &lt;div class="header"&gt;
          &lt;div class="header-item"&gt;
            HEADER ITEM 1
          &lt;/div&gt;
          &lt;div class="header-item"&gt;
            HEADER ITEM 2
          &lt;/div&gt;
        &lt;/div&gt;
        &lt;div class="dashboard"&gt;
          &lt;div class="nav"&gt;
            SOME INNER NAVIGATION
          &lt;/div&gt;
          &lt;div class="table-container"&gt;
          TABLE CONTAINER
            &lt;div class="table"&gt;
              TABLE
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;/div&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>CSS:</p>
  
  <pre><code>.container {
    display: flex;
    margin: auto;
    max-width: 1300px;
    padding: 15px;
    background: lightpink;
  }
  
  .left-container {
    width: 300px;
    background: lavender;
    margin-right: 50px;
  }
  
  .right-container {
    display: flex;
    flex-direction: column;
    width: 100%;
  }
  
  .header {
    display: flex;
    background: lightblue;
    width: 100%;
  }
  
  .header-item {
    flex: 1 1 auto;
  }
  
  .dashboard {
    display: flex;
    flex-direction: column;
    margin-top: 50px;
    max-width: 100%;
  }
  
  .nav {
    background: lightgrey;
  }
  
  .table-container {
    margin-top: 30px;
    background: lavenderblush;
    padding: 5px;
    width: 100%;
    width: 900px;
    overflow-x: scroll;
  
  }
  
  .table {
    background: lightsalmon;
    width: 1500px;
    height: 100px;
  }
  </code></pre>
  
  <p>Also on <a href="https://codepen.io/traceur/pen/RwbEzbP?editors=1100" rel="nofollow noreferrer">codepen</a>.</p>
  
  <p>Table inside the <code>table-container</code> is wider so I want to have <code>overflow-x: scroll</code>. The thing is, right now <code>table-container</code> class has width specified with pixels, <code>width: 900px</code>. 
  That works nice but I would like it to stretch to the full available width of the div with class <code>dashboard</code>. However if I add <code>width: 100%</code> to <code>table-container</code>, it destroys the layout and stretches outside of the div with <code>dashboard</code> class along with all the other sibling divs.</p>
  
  <p><a href="https://i.stack.imgur.com/9D2Gs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9D2Gs.png" alt="Items stretch outside of the container"></a></p>
  
  <p>It seems like the fix should be simple but so far I haven't been successful.</p>