2014-03-03 63 views
0

我坚持着一个问题:我有basicly 4周的div:100%高度减去可变高度

<div id="a">Variable Height: 45px or 90px</div> 
<div id="b">fixed height: 50px</div> 
<div id="c">Has to fill up remaining</div> 
<div id="d">Variable Height: 85px or 40px</div> 

另外:#C可能不是下方,上方#d的。它必须填满,直到#顶部。可以使用填充符,#c的内部可能不会在#d之下/之下/之下。

而这里的CSS:

* { margin:0px; padding:0px; } 
body, html { height:100%; } 
#a { min-height: 45px; width:100%; background: red; max-height:90px; } 
#b { height: 50px; width: 100%; background: orange; float:left;} 
#c {/*Here how to fill up remaining*/ } 
#d { min-height: 40px; max-height: 85px; background: green; float:left; position:absolute; bottom:0px; } 

我不能使用JavaScript,不幸的是,所以我希望有一些可能与CSS!

编辑:

我试图-webkit-计算的,但没有奏效,因为该值必须是静态的。

使用Safari 7.0.2 干杯, 的Douwe

编辑 有一张桌子就解决了问题..需要更多一点外的开箱比我想象!反正谢谢!

+0

请仔细阅读本:http://meta.stackexchange.com/questions/156810/stack-overflow-question-checklist –

+0

为什么你不能用JS? – BFWebAdmin

+0

因为#a和#d的宽度随函数而变化。并且一次又一次地执行规则将不起作用。虽然我更喜欢JS,但在这种情况下,它是不可能的! – douwe12345

回答

0

将c的高度设置为自动或100%适用于Chrome。什么不适合你?

DEMO如果更改两个变量高度div的内容,c的高度会正确更改。

CSS:

* { margin:0px; padding:0px; } 
body, html { height:100%; } 
#a { min-height: 45px; width:100%; background: red; max-height:90px; overflow:hidden; } 
#b { height: 50px; width: 100%; background: orange; float:left;} 
#c { height: 100%;} 
#d { min-height: 40px; max-height: 85px; background: green; float:left; position:absolute; bottom:0px; width: 100%; } 
+0

因为如果将高度设置为100%,它会溢出并占据身体的100%高度。 – douwe12345

+0

这不是在我的演示? – guymid

+0

在我的程序中,不幸的是:-( – douwe12345