What I wanted was a left and right column that auto sizes to its content, then a center column that takes the remaining space.
I've gotten a left, center, and right column layout using css and div's that works for me. However I don't understand why it works. The .left and .right classes make sense and work as planned. The .center class is confusing.
My Two Questions:
Why does "overflow:hidden" cause the center div to start at the right edge of the left div? More specifically, why does the left column area count as overflowed space towards the center column. And why does the right column area not count as overflowed space?
Why does "margin:0 auto" cause the center div's margin-right to equal the size of the right div? More importantly why doesn't margin-left behave the same with the left div?
Excuse me if I'm missing something obvious.
Working Code Example:
<html>
<head>
<style>
body, div{ margin:0;padding:0; }
h1, h2, p{ margin:0 1em; padding:0; color:darkorange;}
#header{
height:2em;
line-height:2em;
overflow:hidden;
}
.left{
float:left;
background:#555;
}
.right{
float:right;
background:#777;
}
.center{
overflow:hidden;
margin:0 auto;
background:#666;
}
</style>
</head>
<body>
<div id="header">
<div class="left"><h1>Chapter Title</h1></div>
<div class="right"><p>Page Number</p></div>
<div class="center"><h2>Page Title</h2></div>
</div>
</body>
</html>