...

View Full Version : How can I make divs appear only if the page reaches a certain height?



cineweekly.com
01-13-2012, 07:33 AM
I don't want my sidebar columns to be too long when the main content is shorter. Is there any way (javascript? jquery? something else?) to only let certain divs load when the main content reaches a certain height?

xelawho
01-13-2012, 02:51 PM
yes, but as far as I am aware you need to set the height of your main content div before you can begin calculating



<body>
<div id="side" style="border-style:dashed; float:left">side
<div id="hidden" style="display:none"> hi there. I'm the hidden div!</div>
</div>
<div id="main" style="border:solid; height:100px; width: 200px; float:left">main</div>
<input type="button" value="grow div" onclick="growDiv()"/>
<script type="text/javascript">
function growDiv(){
theheight=parseInt(document.getElementById("main").style.height);
document.getElementById("main").style.height=theheight+100+"px";
if(theheight>200){
document.getElementById("hidden").style.display="block"
}
}
</script>
</body>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum