Working code (at least firefox9 + ie8)
<div id="outer" style="overflow: hidden; width: 100px;height: 25px; border: #0f0 1px dashed;"> <div id="inner" style="padding: 5px;"> text </div> </div> <input type="button" value="add text" onclick="g('inner').innerHTML += g('inner').innerHTML;animateSlide('outer', g('inner').offsetHeight+10);" /> <input type="button" value="remove text" onclick="g('inner').innerHTML = 'text ';animateSlide('outer', 25);" /> <script type="text/javascript"> function g(id) { return document.getElementById(id); } function animateSlide(id, toHeight) { var slowing = arguments[2] || 0.1; var frameDelay = arguments[3] || 50; var byTimeout = arguments[4] || false; if (!byTimeout && window['anim_slide_'+id]) clearTimeout(window['anim_slide_'+id]); var el = g(id); var dh = Math.ceil((toHeight - el.offsetHeight)*slowing); el.style.height = (parseInt(el.style.height)+dh)+'px'; if (Math.abs(dh) > 0) { window['anim_slide_'+id] = setTimeout('animateSlide("'+id+'", '+toHeight+', '+slowing+', '+frameDelay+', true)', frameDelay); } else window['anim_slide_'+id] = false; } </script>
"плавно"
? when added to a container if it has nooverflow
properties, it will increase in size to fit all the text - chernomyrdin