<!DOCTYPE html>
<style>
.fieldset {
  border: 2px solid gray;
  margin: 1em;
  padding: 0;
  width: 20em;
}

.f1 {
  overflow: auto;
  max-height: 3em;
}
.f2 {
  max-height: 0;
}
</style>

<div class="fieldset f1">
<div>foo</div>
<div>foo</div>
<div>foo</div>
<div>foo</div>
<div>foo</div>
</div>

<div class="fieldset f1">
<div>foo</div>
</div>

<div class="fieldset f2">
<div>foo</div>
</div>

