开发者

Dynamic div content, but need a fixed div height

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?


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?


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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜