views:

26

answers:

2

Hello. I'm using javascript to animate a div collapsing/sliding. The javascript requires the div to have a set height, although the content inside the div is dynamic. How would I go about making it work, as I don't want the div to be any larger than it's meant to. I've set the height of the div like this:

<div id="main-div" style="overflow:hidden; height:95px;">

I've tried setting the height to 'auto' but when the div slides open again, it doesn't slide to the correct height. Would I need to calculate the height? Thanks.

A: 

You don't want 'auto' as that means "fit the box height to the content height." Are you saying that setting the height attribute is not working? What is your full div markup?

bmoeskau
A: 

Try setting min-height and max-height as well.

And I'm not sure I understand your question. Do you have a problem with your current approach? What is that problem?

Fyodor Soikin