Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hide div tag (collapse)

Status
Not open for further replies.

FancyPrairie

Programmer
Oct 16, 2001
2,917
US
I have 2 div tags:
<div id=div1 ...></div>
<div id=div2 ...></div>

I want div2 to be displayed right below div1.

However, when I set div1.style.display="none", I would expect div1 to collapse and the top position of div2 would move up to where div1 use to be. I've done this before and thought it had to do with setting up a style like this:

<STYLE type=text/css media=screen>
#div1 {DISPLAY: none !important}
#div2 {Display: block !important}
</STYLE>

But it doesn't seem to work.

What am I missing?
 
Never mind. I figured out the problem. I had div1 as position: absolute rather than relative.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top