I have a site with the following structure:
<div id="header"></div>
<div id="main">
<div id="navigation"></div>
<div id="content"></div>
</div>
<div id="footer"></div>
The navigation
is on the left and the content
div
is on the right. The information for the content
div
is pulled in through PHP, so it's different every time.
How to scale the navigation
vertically so that its height is the same as the content div
's height, no matter which page is loaded?
I know it's been a looong time since the question was made, but I found an easy solution and thought someone could use it (sorry about the poor english). Here it goes:
CSS
HTML
Simple example. Note that you can turn into responsiveness.
As shown earlier, flexbox is the easiest. eg.
this will align all child elements to the center within the parent element.
[Referring to Dmity's Less code in another answer] I'm guessing that this is some kind of "pseudo-code"?
From what I understand try using the faux-columns technique that should do the trick.
http://www.alistapart.com/articles/fauxcolumns/
Hope this helps :)
giving
position: absolute;
to the child worked in my caseNOTE: This answer is applicable to legacy browsers without support for the Flexbox standard. For a modern approach, see: https://stackoverflow.com/a/23300532/1155721
I suggest you take a look at Equal Height Columns with Cross-Browser CSS and No Hacks.
Basically, doing this with CSS in a browser compatible way is not trivial (but trivial with tables) so find yourself an appropriate pre-packaged solution.
Also, the answer varies on whether you want 100% height or equal height. Usually it's equal height. If it's 100% height the answer is slightly different.
The easiest way to do this is to just fake it. A List Apart has covered this extensively over the years, like in this article from Dan Cederholm from 2004.
Here's how I usually do it:
You can easily add a header onto this design by wrapping #container in another div, embedding the header div as #container's sibling, and moving the margin and width styles to the parent container. Also, the CSS should be moved into a separate file and not kept inline, etc. etc. Finally, the clearfix class can be found on positioniseverything.