I have a div
that functions as an information box, giving extra information on the item it is associated with. Now this div
might contain any amount of content, so I cannot fix the height in the css. This would be fine, but I would also like this div to have a nice transition when the user opens it, and this is where I run into a problem. I have all the transitions working correctly, and they are here (+ open/closed css)
#info.hidden {
opacity:0;
width:0px;
height:10px;
transition: width .5s ease-in-out, height .5s ease-in-out, opacity .5s ease-in-out, visibility 0s linear .5s;
/* with -moz- & -webkit- */
}
#info.visible {
width:150px;
transition: width .5s ease-in-out, height .5s ease-in-out, opacity .5s ease-in-out;
/* with -moz- & -webkit- */
}
The problem I have is that the small width during the transition causes the text to wrap, extending the height of the box and not having the desired effect. Ideally, the height would expand smoothly from 10px to the height of the text, but instead it follows the bottom of the text all the way through the transition. Also on close the height jumps straight to 10px.
This problem can be seen here: http://jsfiddle.net/Daniel300/1nhs9w78/.
I have tried various things, including adding a wrapper div to the text, hoping that the wrapper div would overflow past the bottom (or the side) of the div during the transition. I also messed about with the display
and overflow
properties, but nothing seemed to work.
Thanks for any help!