calc()
.The expression calc(100vh - 30px)
represents the remaining height. Where 100vh
is the height of the browser and the usage of calc()
effectively displaces the height of the other element.
body {_x000D_
margin: 0;_x000D_
}_x000D_
.banner {_x000D_
background: #f00;_x000D_
height: 30px;_x000D_
}_x000D_
iframe {_x000D_
display: block;_x000D_
background: #000;_x000D_
border: none;_x000D_
height: calc(100vh - 30px);_x000D_
width: 100%;_x000D_
}
_x000D_
<div class="banner"></div>_x000D_
<iframe></iframe>
_x000D_
Support for calc()
here; support for viewport relative units here.
Set the display
of the common parent element to flex
, along with flex-direction: column
(assuming you want the elements to stack on top of each other). Then set flex-grow: 1
on the child iframe
element in order for it to fill the remaining space.
body {_x000D_
margin: 0;_x000D_
}_x000D_
.parent {_x000D_
display: flex;_x000D_
flex-direction: column;_x000D_
min-height: 100vh;_x000D_
}_x000D_
.parent .banner {_x000D_
background: #f00;_x000D_
width: 100%;_x000D_
height: 30px;_x000D_
}_x000D_
.parent iframe {_x000D_
background: #000;_x000D_
border: none;_x000D_
flex-grow: 1;_x000D_
}
_x000D_
<div class="parent">_x000D_
<div class="banner"></div>_x000D_
<iframe></iframe>_x000D_
</div>
_x000D_
Since this approach has less support1, I'd suggest going with the aforementioned approach.
1Though it seems to work in Chrome/FF, it doesn't work in IE (the first method works in all current browsers).