如何强迫孩子Div到100%的父母的Div而不指定父母的身高?

问题描述:

我认为这是可能的,但我只是无法想象它。

I would assume this is possible, but I just cant figure it out..

我有一个网站的基本结构设置如下。

I have a site thats basic structure is set up as follows.

<div id="header"></div>

<div id="main">
  <div id="navigation"></div>
  <div id="content"></div>
</div>

<div id="footer"></div>

导航是左侧导航,其右侧有一个内容div。我想垂直缩放导航与内容div相同的高度取决于什么被加载到内容div。内容div的信息通过PHP被拉入,所以每次都是不同的。反正长故事短。有没有办法设置它,使我的导航永远是内容div的整个高度,无论加载哪个页面?

The navigation is a left hand navigation with a content div to the right of it. I would like to scale the navigation vertically to be the same height as the content div depending on what is loaded into the content div. the information for the content div is pulled in through PHP, so it is different every time. anyway long story short. Is there a way to set it so that my navigation will always be the full height of the content div no matter which page is loaded?

我建议您查看等高列有跨浏览器CSS和没有黑客

基本上,使用CSS在浏览器兼容的方式是这样做不是微不足道(但微不足道的表),所以找到一个适当的预打包解决方案。

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.

此外,答案取决于你是否想要100%的高度或相等的高度。通常它的高度相等。如果是100%的高度,答案稍有不同。

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.