title: CSS to make line items text wrap
body: <p>How can I extend the vertical size of a <code>&lt;li&gt;</code> when text wrapping is required, but keep a minimum value?</p>
  <p><a href="https://i.stack.imgur.com/63J1D.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/63J1D.png" alt="enter image description here" /></a></p>
  <p>The look of this is exactly what I want when the text is short enough to fit on one line. But if the text is longer (I'm not expecting more than 2 lines), it gets cut.</p>
  <p>My HTML looks like this:</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>.items {
    margin: 0 0 2em 0;
    list-style-type: none;
    padding: 0em 0.5em;
    width: 20em;
  }
  
  .items li {
    cursor: pointer;
    position: relative;
    left: 0.2em;
    background-color: #EEE;
    margin: .3em;
    padding: .3em 0;
    height: 1.6em;
    border-radius: 4px;
  }
  
  .items li.test {
    font-weight: bold;
  }
  
  .items .badge {
    display: inline-block;
    font-size: small;
    color: white;
    padding: 0.8em 0.7em 0 0.7em;
    background-color: #607D8B;
    line-height: 1em;
    position: relative;
    left: -1px;
    top: -4px;
    height: 1.8em;
    margin-right: .8em;
    border-radius: 4px 0 0 4px;
    width: 2em;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;ul class="items"&gt;
    &lt;li class="test"&gt;
      &lt;span class="badge"&gt;0&lt;/span&gt;
      This is a long string that doesnt fit on one line.
      Need to extend this box vertically
    &lt;/li&gt;
    &lt;li class="test"&gt;
      &lt;span class="badge"&gt;0&lt;/span&gt;
      Next item
    &lt;/li&gt;
  &lt;/ul&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>My problem with changing <code>.items li { height: 1.6em; }</code> to <code>max-height</code> is I end up with this:</p>
  <p><a href="https://i.stack.imgur.com/cis07.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cis07.png" alt="enter image description here" /></a></p>
  <p>I don't mind the messed up long string, but the height of the second <code>&lt;li&gt;</code> is now larger.</p>