获取CSS Div以填充可用的高度 [英] Get CSS Div to fill available height
问题描述
我有一个有2个元素的div。
I have a div with 2 elements.
<div id="master">
<div id="follower"></div>
<div id="decider"></div>
<div>
'master'div具有以下CSS属性
'master' div has the following CSS properties
height:auto;
width:auto;
margin:0;
padding:10px;
display:block;
追随者div具有以下CSS属性
The 'follower' div has the following CSS properties
position:relative;
vertical-align:middle;
height: auto;
display: inline-block;
margin-top: 0px;
margin-bottom:0px;
'decider'div决定'master'div的高度。
The 'decider' div decides how tall the 'master' div is. Is it possible for the 'follower' div to fill up as much vertical space in the 'master' div as possible?
我尝试了 height:'div'
I tried height: 100%
but that just made the 'follower' div take up the whole screen (vertically)
推荐答案
主人应该有
position: relative;
,然后追随者应有
position: absolute;
top: 0;
bottom: 0;
这应该可以工作,除了IE6(这是一个惊人的人仍在使用,只是忽略那些并告诉他们更新他们的浏览器)
That should work, except in IE6 (which an alarming amount of people are still using, but I would just disregard those and tell them to update their browser)
这篇关于获取CSS Div以填充可用的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!