title: :before element with float:left causing overflow
body: <p>My container has a list of items with <code>display: inline-block</code> and a <code>::before</code> element that uses <code>float:left</code>. This is causing the last item to overflow the container in specific cases, like this:</p>
  <p><a href="https://i.stack.imgur.com/TdB2U.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TdB2U.png" alt="Container overflowing" /></a></p>
  <p>The floating element is depicted here using a dashed border. I'm following <a href="https://css-tricks.com/hexagons-and-beyond-flexible-responsive-grid-patterns-sans-media-queries/" rel="nofollow noreferrer">this tutorial</a>, so I'm unable to change the floats and inline-blocks to more modern solutions like Flexbox and Grid.</p>
  <p>I've tried adding clearfixes everywhere, with no success. Help?</p>
  <p>Here is a working fiddle, just resize the output panel until you reach the overflow point:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>body {
    background-color: #DDD;
  }
  
  .main {
    background-color: teal;
    padding: 1rem;
    min-height: 80px;
    display: flex;
    transition: height 500ms linear;
  }
  
  .container&gt;div {
    display: inline-block;
    font-size: initial;
    margin: 0.5rem;
    vertical-align: top;
  }
  
  .container::before {
    content: '';
    width: 1.75rem;
    float: left;
    height: 100%;
    border: 1px dashed #DDD;
  }
  
  .item {
    position: relative;
    width: 3.5rem;
    height: 3.5rem;
  }
  
  .item-inner {
    box-sizing: border-box;
    height: 100%;
    width: 100%;
    border-radius: 100%;
    border: 0.125rem solid chocolate;
    overflow: hidden;
  }
  
  .item-inner img {
    width: 100%;
    height: 100%;
  }
  
  .clearfix {
    clear: both;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;main class="main"&gt;
    &lt;div class="container"&gt;
      &lt;div class="item"&gt;
        &lt;div class="item-inner"&gt;
          &lt;img src="https://pbs.twimg.com/profile_images/1289324739794735104/mQoHcZfq_400x400.jpg" /&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="item"&gt;
        &lt;div class="item-inner"&gt;
          &lt;img src="https://pbs.twimg.com/profile_images/1289324739794735104/mQoHcZfq_400x400.jpg" /&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="item"&gt;
        &lt;div class="item-inner"&gt;
          &lt;img src="https://pbs.twimg.com/profile_images/1289324739794735104/mQoHcZfq_400x400.jpg" /&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="item"&gt;
        &lt;div class="item-inner"&gt;
          &lt;img src="https://pbs.twimg.com/profile_images/1289324739794735104/mQoHcZfq_400x400.jpg" /&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="item"&gt;
        &lt;div class="item-inner"&gt;
          &lt;img src="https://pbs.twimg.com/profile_images/1289324739794735104/mQoHcZfq_400x400.jpg" /&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="item"&gt;
        &lt;div class="item-inner"&gt;
          &lt;img src="https://pbs.twimg.com/profile_images/1289324739794735104/mQoHcZfq_400x400.jpg" /&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="item"&gt;
        &lt;div class="item-inner"&gt;
          &lt;img src="https://pbs.twimg.com/profile_images/1289324739794735104/mQoHcZfq_400x400.jpg" /&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="item"&gt;
        &lt;div class="item-inner"&gt;
          &lt;img src="https://pbs.twimg.com/profile_images/1289324739794735104/mQoHcZfq_400x400.jpg" /&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/main&gt;</code></pre>
  </div>
  </div>
  </p>