187
rated 0 times
[
188]
[
1]
/ answers: 1 / hits: 21726
/ 10 Years ago, fri, september 19, 2014, 12:00:00
I have a div with preset width and height. I need to change the height of that div based on content. I was looking for some JavaScript but couldn't find appropriate for me.
Here is my simple example, which needs an improvement http://jsfiddle.net/dmitry313/1zr6Lhwa/
HTML
<div id=content>
<h2>Text</h2>
<p>Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example Example </p>
</div>
CSS
h2 {
font:18px/30px Arial;
}
#content {
width:200px;
height:100px;
border:1px solid #000;
background: yellow;
}
EDIT: Initially preset width and height are important and can't be changed
More From » jquery