Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
|
The easiest way is to make the box absolutely positioned, then don't set a width or a height on it. Absolutely positioned divs without height and width attributes will adjust automatically to fit their content. You could, alternatively, set a max-width characteristic, though this won't work in IE6, and may cause some browser compatibility issues.
If you want to center the box, however, you will need to calculate the widths with JavaScript, using the offsetWidth property. You may have to do a little research for this, because calculating the width is not always accurate on absolutely positioned items, at least not in IE.
Reading your post again, I'm not totally sure what you mean by "dynamic". The reason this is confusing to me is that simply stating that you want the box to change with the content isn't a very accurate description. There are many ways a box could stretch to accommodate text. The example I gave will never end up looking like the example you linked to, since it would first stretch to fill the browser horizontally before it ever expanded vertically.
Does this help?
__________________
I build web things. I work for the startup Please login or register to view this content. Registration is FREE
.
|