Skip to content

Instantly share code, notes, and snippets.

@ZeeAgency
Created February 9, 2012 13:10
Show Gist options
  • Save ZeeAgency/1779872 to your computer and use it in GitHub Desktop.
Save ZeeAgency/1779872 to your computer and use it in GitHub Desktop.
Auto-height Hack
<!doctype html>
<style type="text/css">
.outer {
width: 200px;
height: 200px; /* 200px = list's height, outer will end to 300px */
padding: 50px 0; /* Here's the Hack */
border: 1px dotted red; /* to aid debugging */
}
.header, .footer {
height: 50px;
border: 1px dotted blue; /* to aid debugging */
}
.header {
margin-top: -50px; /* Here's the Hack */
}
.list {
height: 100%; /* this should end up approx 200px once the 50px header and footed are subtracted from the 300px container height */
overflow: auto;
border: 1px dotted green; /* to aid debugging */
}
.list ul {
margin: 0px;
padding: 0px;
}
</style>
<div class="outer">
<div class="header">header</div>
<div class="list">
<ul>
<li>Blah</li>
<li>Blah</li>
<li>Blah</li>
<li>Blah</li>
<li>Blah</li>
<li>Blah</li>
<li>Blah</li>
<li>Blah</li>
<li>Blah</li>
<li>Blah</li>
<li>Blah</li>
<li>Blah</li>
<li>Blah</li>
<li>Blah</li>
<li>Blah</li>
<li>Blah</li>
<li>Blah</li>
<li>Blah</li>
<li>Blah</li>
<li>Blah</li>
<li>Blah</li>
<li>Blah</li>
<li>Blah</li>
</ul>
</div>
<div class="footer">footer</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment