Control a <DIV> elements size to fit dynamic content.
Posted on 2010-08-23
I have a <DIV> element in HTML that I want to dynamically populate. What I want is to be able to expand this <DIV> element to fit the dynamic content. At the moment I am using the following code (which fulfills part of my needs)...
This works in that whatever content I put within the <DIV> the the border fits the content. This is where I run into a problem, I want the <DIV> to have a minimum horizontal size e.g. 200px - this is purely for display purposes, but I still want the horizontal size to expand if the content exceeds this? I also want the same effect with the vertical size of the <DIV> element with the additional exception that the size should never exceed a given size e.g) 80px.
Does anyone know how to acheive this?