I have a setup with two side panels, one as float:left and one as float:right, and an iframe in between them. I want the two side panels to always have a width of 150px, and the iframe to fill the rest of the page. I am attempting to do this using jQuery to make functions that change the iframe width dynamically when the window is resized, yet it is not working. Here is what I have so far:
<body>
...
<script src="jquery.js">
function setFrameSize() {
$("#ifrm").width($(window).width() - $("#leftPanel").width() - $("#rightPanel").width());
}
$(window).resize(function() { setFrameSize(); });
$(document).ready(function() { setFrameSize(); });
</script>
...
</body>
Can anyone tell me why this is not working? Thanks!
It’s much better to do it with CSS:
http://jsfiddle.net/7pbJb/
HTML:
CSS:
Setting the left and right position of the center div causes it to stretch.