Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > <div> height auto resize

<div> height auto resize
Thread Tools
Mac Elite
Join Date: Jan 2000
Location: Pittsburgh, PA
Status: Offline
Reply With Quote
Aug 15, 2004, 11:45 PM
 
There has to be a really simple solution to this that I'm missing, but I searched and couldn't find any answers.

I know a div can have its height set to "auto" and will adjust based on images, tables, text inside it. But is there a way to make the div resize based on other divs that are encased within it? I know that the divs aren't really inside it. other than their placement in the code, but is there a way to make the base div resize based on the other divs inside it? Thanks in advance.

spike[at]avenirex[dot]com | Avenirex
IM - Avenirx | ICQ - 3932806
     
Dedicated MacNNer
Join Date: Nov 2001
Location: Are Eye
Status: Offline
Reply With Quote
Aug 16, 2004, 07:55 AM
 
a div will automagically expand to hold its contents as long as its contents is not floated or positioned absolutely. (that is to say relative)

so if you have

<div class="container">
<div class="blah">blah</div>
<div class="wow">wowee wow wow wow</div>
</div>

div.container will extend vertically to contain div.blah and div.wow regardless of their heights.

Floated and absolutely positioned elements are removed from the document's flow however. So if you were to set div.blah and div.wow to position: absolute, then div.container will have a height of 0 because all of its children are positioned outside of the document's flow.
     
Avenir  (op)
Mac Elite
Join Date: Jan 2000
Location: Pittsburgh, PA
Status: Offline
Reply With Quote
Aug 17, 2004, 05:43 PM
 
Synotic has held my hand and walked me through it all. I was using absolute positioning (which I know now is a bad, bad, bad thing, always). So, I'm ok for now.

spike[at]avenirex[dot]com | Avenirex
IM - Avenirx | ICQ - 3932806
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 01:09 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2