Forum Moderators: not2easy

Message Too Old, No Replies

css spacing problem

         

jackvull

12:07 pm on Jun 2, 2006 (gmt 0)

10+ Year Member



Hi
I am trying to hide/unhide a div element. However, when it is unhidden, the whole spacing changes.
Any ideas on how to solve this?
Thanks.

#menu2 div, #menu2 a
{
display:none;
position:relative; top:-18px; left:110px;

padding: 2px 2px 2px 2px;
background-color:#D8D8D8;
border : 1px solid #aaa;
text-align: left;
vertical-align: top;
width: 115px;
}

<a class='button' href='index.php'>New Menu</a>
<div id='menu2' ><a href='index.php'>New Menu2</a></div>
<a class='button' href='index.php'>New Menu 2</a>

choster

2:19 pm on Jun 2, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you want the browser to act as if the element did not exist, use display:none, but if you want the browser to reserve the space and other aspects of the element and simply not display it, use visibility:hidden .

jackvull

2:37 pm on Jun 2, 2006 (gmt 0)

10+ Year Member



Yeah, the problem is that when I use some javascript to set it back to display:inline-block, a space appears after the element even though I have repositioned it relatively

londrum

8:44 pm on Jun 2, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



you've got a <div> wrapped around that anchor, whereas the other anchors don't - so its probably to do with that. try putting margin:0;padding:0 on the div.

or remove the <div> completely, and put the id='menu2' on the actual anchor itself.