2011-07-27 504 views
0

我有3周的div堆叠在彼此的顶部:DIV填满所有剩余的白色空间(未3列)

  • DIV1 20像素
  • DIV2占用剩余的屏幕高度
  • DIV3 20像素

如何让div2占用剩余的屏幕高度?

注意:我不想使用JavaScript。

+0

你试图给中间的div宽度:100% – Ibu

回答

3
<div id="top"></div> 
<div id="middle"></div> 
<div id="bottom"></div> 

#top,#bottom { 
    position:absolute; 
    height:20px; 
    left:0; 
    right:0; 
} 
#top { top:0; } 
#bottom { bottom:0; } 
#middle { 
    position:absolute; 
    top:20px; 
    bottom:20px; 
    left:0; 
    right:0; 
} 

它应该工作。

+0

这项工作太棒了!谢谢! #middle的top/bottom:0px是我所需要的。 – kev

+0

不客气!不要忘记检查我的答案,以表明您的问题已解决=) – MatTheCat

1

也许是这样的:

<div id="top"> 
    top div 
</div> 
<div id="middle"> 
    middle div 
</div> 
<div id="bottom"> 
    bottom div 
</div> 

#top { 
    height: 20px; 
} 

#bottom { 
    height: 20px; 
    bottom: 0; 
    position: absolute; 
    width: 100%; 
} 

看到这个代码在行动: http://jsfiddle.net/PzA3W/