Welcome to WebmasterWorld Guest from 18.208.159.25

Forum Moderators: open

Message Too Old, No Replies

Hiding a <DIV> element

And reclaiming the space it took

     
10:49 am on Dec 5, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Aug 31, 2003
posts:196
votes: 0


I did some Javascript hiding of a DIV element a few days ago, but when I hid it, the space it took up when it was visible was still taken up.

The construct is a DIV element with a table enclosed. Everything becomes invisible, but I'd like the elements below the DIV to move up the page...

Any suggestions?

dcrombie

11:57 am on Dec 5, 2003 (gmt 0)

Inactive Member
Account Expired

 
 


AFAIK, the behaviour in this situation is "undefined" in CSS. The documentation states that different user-agents may behave differently in these cases (they refer to changing the widths of elements but I think it still applies to your case).
1:06 pm on Dec 6, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Aug 31, 2003
posts:196
votes: 0


Bugger. Thanks anyway! ;)
1:11 pm on Dec 6, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 22, 2002
posts:2546
votes: 0


Are you using the visibility or display property to hide the div? I may be wrong, but I think using display: none; will take the element and the space out of the document. Worth a try, I guess.
10:05 am on Dec 8, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Aug 31, 2003
posts:196
votes: 0


I'll try, I was using display.visibility=hidden...
1:36 pm on Dec 8, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member blobfisk is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Feb 25, 2002
posts:3185
votes: 0


As birdman suggested, use display:none;

In a DOM1 environment, you could use a function like:


function showLayer(layerID) {
document.getElementById(layerID).style.display='block';
}

function hideLayer(layerID) {
document.getElementById(layerID).style.display='none';
}

HTH