tags:

views:

52

answers:

2

Hello All:

I have one div with predefined width (say 80px), but the length of the content in the div can be long, can any body tell me how to increase the width of div based on content length?

my div looks like

    <div class="content">
Text here
</div>

I have tried to use jQuery to resize it, but I am always getting 0 value when I am using .width() or .innerWidth() functions.

Thanks Ashwani

+1  A: 

Sounds like overkill to me. If possible, just modify the CSS from your div to:

div.content {
   min-width:  80px;
   min-height: 80px;
}

That should ensure the div still expands dynamically if neccessary.

jAndy
+1  A: 

min-width doesn't work in IE6. Here's a hack.

SiN
that is overkill aswell, fits much better as a comment
jAndy