I have three iframes and I set the top iframe to 50px height and I set the bottom iframe to 50px, but I want the middle iframe to exand to fill the rest of the space. Is there a technique I can use to do this for any window screen size? thanks.
example:
<iframe style="width:100%; height:50px;" src="headerstuff.asp" %></iframe>
<iframe style="width:100%; height:100%;" src="Content.asp" %></iframe> <!-- height needs to fill -->
<iframe style="width:100%; height:50px;" src="footerstuff.asp" %></iframe>
You can use
$(window).height();
and$(window).width();
to get the dimensions of the browser viewport. From there you can resize based on your content.Sorry. I forgot to wrap
window
in a jQuery object.Also: This code assumes no borders, margin etc. Out of the box, iframes get these, so you'd need to get rid of them or take them into account in the subtraction of other iframe's heights.
For divs, this is pretty simple. I'm not sure if this will work for iframes, but your question title indicates divs are sufficient:
This might be the answer to your question:
Taken from this website, found on google.
Just for the redundancy: Set your iframe width and height to 100% and make the enclosed containers, divs or table cells fit the content as you wish. The width and height of an iframe is relative to the parenting container.