title: How can I stop a <ul> element from overflowing the bounds of its container?
body: <p>I am trying to create a simple fixed-height box in CSS, with a title at the top, and an arbitrary-length list of elements below. I would like <em>only</em> the list to be scrollable, while the title remains visible and fixed at the top.</p>
  
  <p><a href="https://i.stack.imgur.com/KuQgm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KuQgm.png" alt="enter image description here"></a></p>
  
  <p>Here is a codepen:<br>
  <a href="https://codepen.io/anon/pen/qJRBpo?editors=1100" rel="nofollow noreferrer">https://codepen.io/anon/pen/qJRBpo?editors=1100</a></p>
  
  <pre><code>&lt;div class="outerdiv"&gt;
    &lt;h4&gt;This is my title&lt;/h4&gt;
  
    &lt;div class="innerdiv"&gt;
      &lt;ul&gt;
        &lt;li&gt; List item 1 &lt;/li&gt;
        &lt;li&gt; List item 2 &lt;/li&gt;
        &lt;li&gt; [...] &lt;/li&gt;
      &lt;/ul&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I would think setting <code>overflow: auto</code> on either <code>.innerdiv</code> or <code>ul</code> elements would be enough, but these two elements seem to size themselves according to the content of the <code>&lt;ul&gt;</code>, completely ignoring the bounds of the <code>.outerdiv</code> box.</p>
  
  <p>I have not found a way to constrain the <code>.innerdiv</code> or <code>ul</code> elements to grow no bigger than the size of <code>.outerdiv</code>. They always size themselves independently of the rest of the layout, and then, depending on the <code>overflow: visible|auto</code> setting on <code>.outerdiv</code>, the best I can do is clip or scroll the <em>entire</em> contents of the <code>.outerdiv</code>, including the title.</p>