Click to See Complete Forum and Search --> : dynamically size the div


ixxalnxxi
06-30-2009, 12:49 AM
hello all,

i have a container that holds an image. the default with of the div is auto and so the div likes to take 100% of the available space. however i would like for the div to somehow resize based on its contents. is this possible? if so, how would i accomplish this? thanks.

ScKaSx
06-30-2009, 03:47 AM
I'm not an expert, but I think this is something that needs to be done in javascript. Here's a good link for learning how to change divs with javascript (http://javascript.about.com/od/animationtutorials/Animation_Tutorials.htm).

What sort of contents are you trying to change, images? If so, then I think you will need to know the sizes of the images before you run them with javascript. However, if they are divs in the webpage, then the author of the link I posted has functions to find sizes of divs which you can then use reposition.

Hope that helps.

Cheers,
ScKaSx

ixxalnxxi
06-30-2009, 06:27 PM
there must be a simpler way, let me change the scenario a bit:

a description div box, with a different color than that of it's background, that has a variable amount of text in it. assigning a width would keep the box at a constant width. not assigning anything would make the div take all the width available. is there not a way that the box would re-size according to it's contents?