Dynamically change width of div when content is more on load
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.
Tha开发者_Go百科nks Ashwani
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.
min-width doesn't work in IE6. Here's a hack.
精彩评论