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?
height : <percent>
will only work if you have all parent nodes with specified percent height with a fixed height in pixels, ems, etc. on top level. That way, the height will cascade down to your element.You can specify 100% to html and body elements as @Travis stated earlier to have the page height cascading down to your nodes.
For the parent:
You should add some prefixes, http://css-tricks.com/using-flexbox/.
Edit: As @Adam Garner noted, align-items: stretch; is not needed. Its usage is also for parent, not children. If you want to define children stretching, you use align-self.
This is a frustrating issue that's dealt with designers all the time. The trick is that you need to set the height to 100% on BODY and HTML in your CSS.
This seemingly pointless code is to define to the browser what 100% means. Frustrating, yes, but is the simplest way.
I find that setting the two columns to
display: table-cell;
instead offloat: left;
works well.In a RWD project, the best would be to use jQuery. For a small screen you would probably want to keep the height auto as the col1, col2 and col3 are stacked on one another.
However after a media query breakpoint you would like cols to appear next to each other with an equal height for all columns.
1125 px is only an example of window width breakpoint after which you would want to make all columns set to the same height.
You could, of course, set more breakpoints if you need to.
After long searching and try, nothing solved my problem except
on the children div
and for parent apply this
also, I am using bootstrap and this did not corrupt the responsive for me.