I have one main DIV container (orange) and a few floating DIV containers inside (gray and red). These inner DIVs have some content and main DIV has to fit to the height of one which have higher height. Problem I'm facing is related to very first DIV (gray one). Depending of content inside that DIV I have to keep it at max height, so if it’s shorter than any other DIV it needs resize to max height, if it’s larger main DIV fits to its size.
That DIV also contains two DIVs which I’m trying to position, one at the top, and another one at the bottom of DIV. Whatever I tried so far, failed.
I’m sure that CSS properties position
and bottom
(or top
) are relevant to solve this but any combination I have tried so far didn’t help.
<!-- MAIN CONTAINER: Orange -->
<div style="overflow:hidden; width:550px; background-color:#ffcc00">
<!-- INNER CONTAINER #1: Gray -->
<div style="overflow:hidden; float:left; width:180px; margin:5px 5px; background-color:#eeeeee">
<!-- TOP BLOCK -->
<div style="">This block goes top!</div>
<!-- BOTTOM BLOCK -->
<div style="">This block goes bottom!</div>
</div>
<!-- INNER CONTAINER #2: Red -->
<div style="overflow:hidden; float:left; width:250px; margin:5px 5px; background-color:#ff0000">Not that important block<br />with some content<br />...</div>
</div>
To keep my code clear I post just simple structure and need CSS solution to get it works. I can also post complete code but respect your time and there’s probably nobody crazy enough to read tones of irrelevant lines.
Course, margin
and background-color
properties are here just to provide visual aid.
So basically my question is: How to keep Inner DIV #1 at max HEIGHT compared to all other inner DIVs and how to make top and bottom DIVs work inside parent element. Course, I don't need top and bottom blocks mix one atop another if they are huge, than they have to increase size of parent DIV (and main container).
Surely, I can do it easily with JavaScript workaround, dealing with offsetHeight property of elements but that can't be solution (CSS only). Also, I don't request for whole cross-browser solution, anything that works with IE8+ and newer Chrome, Firefox and Opera browsers is perfectly acceptable for me.
I was searching SO and other relevant resources for days but couldn't find anything usable. Not even sure it's possible now. So if there's anything I can do to make it works, let me know, any comment, suggestion, tip or trick is warmly welcome.
Examples of my goal:
At the end, I want to simulate this effect (somehow) with DIVs and CSS only.
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="200" valign="top">Top</td>
<td width="350" rowspan="2" valign="top">Side</td>
</tr>
<tr>
<td valign="bottom">Bottom</td>
</tr>
</table>