views:

37

answers:

2

I have a <h3> tag with limited height (100 px for example, position: absolute) and the text overflows it.

What I would like to do is slide it down over to the height that is needed when the mouse is over it and back to original height (100px).
I hope you understood what I mean

I don't think it uses slidedown() function for that and I am very weak in animate function. Any help please?

+3  A: 

You can nest a div inside the h3 that contains the content and then use the h3 as a masking container (use overflow:hidden). When the user mouses over, fire a function that get's the height of the interior div (make sure to include any margins or padding). Then execute you height adjust animate function (In jquery, something like $('h3').animate({height: heightVar}); )The mouseout fires a function that restores the height of the h3 back to 100px.

Here's a sample: http://jsfiddle.net/XR9fb/

Brian Flanagan
or you could just use .hover() so you don't have to use .mouseover() and .mouseout() - http://drp.ly/QoMh
Koes Bong
A: 

You can get the real height of the element with the scrollHeight property. Now, I don't really know much of jQuery, but I imagine you could just call animate to set the height CSS property to the scrollHeight of the element when the mouse hovers it, and return to the original height when the mouse moves out of it.

If the height of the element isn't fixed, you can salve the current height somewhere before displaying the full element, and when the mouse leaves the element you just restores this state.

killdream