My apologies if similar questions already exist (I know they do), but I didn't really find what I was looking for and I'm getting crazy here. I want the solution to work on Chrome; compatibility with other browsers is optional.
Let me draw a picture of what I want, hoping my ASCII art won't get messed up. The line of x
s represents the page width:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ,-----------. ,---. | Contents | | | ,--------. | | | B | | some C | | A | | | `--------' `-----------' `---'
A and B should be as close of each other as possible, and A should touch the left of my window. C should touch the right of my window. Between B and C is an empty area that varies with respect to the three elements sizes. If C has a smaller height than A or B, I want it to be centered vertically on the line. I'd like to not to use javascript for layout.
I tried many things, among which:
(This sort of thing would be trivial in any modern GUI toolkit. Why are the web standards lagging so far behind?)
HTML:
<div class="left main">
<div class="container">
<div class="contents"></div>
</div>
</div>
<div class="center main">
<div class="container">
<div class="contents"></div>
</div>
</div>
<div class="right main">
<div class="container">
<div class="contents"></div>
</div>
</div>
CSS:
div{
height:100px;
}
.main{
display:table;
}
.left{
background:blue;
width:65px;
float:left;
}
.center{
background:green;
width:100px;
float:left;
}
.right{
background:orange;
width:65px;
float:right;
}
.container{
display:table-cell;
vertical-align:middle;
}
.contents{
margin:auto;
height:20px;
width:20px;
background:lightGrey;
}