...

View Full Version : How to autoresize the DIV



guryu
10-16-2006, 08:09 AM
Hello all!
I hava 3 DIV's in one page, and the height of first and second was fixed.
I want to that the third DIV 's height was autoresized when the browser's size was changed. For example adjustment by the user.

Details:
1.The height of the first and second was fixed.
2.The height of the third was fixed too but resizeable by the JavaScript
3.Three of the DIV's Width was fixed by the 100%.

expectancy:
When the size of the browser was changed by the user,the height of the third DIV was autoresized to fit the browser.

Thanks!
guryu
20061016

Kor
10-16-2006, 01:43 PM
make it clear the CSS (or whchever) relationship betweens all your DIVs. Can we see a shortened variant of your code? (the position of your DIVs and the relationship between them)

guryu
10-19-2006, 12:30 AM
make it clear the CSS (or whchever) relationship betweens all your DIVs. Can we see a shortened variant of your code? (the position of your DIVs and the relationship between them)


My code is as below,but I wan to make it all by JavaScript.
------------------------------------------------------------------
<script type="text/javascript">
<!--
function modeTest()
{
return (document.compatMode && document.compatMode!="BackCompat")?
document.documentElement:document.body;
}

onresize = function()
{
var Elementy = document.documentElement.scrollHeight? document.documentElement.scrollHeight:modeTest().scrollHeight;
var td1 = document.getElementById("td1").clientHeight;
var td2 = document.getElementById("td2").clientHeight;
var td3 = document.getElementById("td3").clientHeight;
var td4 = document.getElementById("td4").clientHeight;
var div1 = 150;
var div2 = 150;

document.getElementById("div3").style.height = Elementy -(td1+td2+td3+td4+div1+div2)+"px";

window.onresize = modeTest();

}

//-->
</script>
------------------------------------------------------------------------



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum