How to make jquery mobile collapsible content appear with animation using css transition?
.ui-collapsible {
-webkit-transition: all 1s;
-moz-transition: all 1s;
-ms-transition: all 1s;
-o-transition: all 1s;
transition: all 1s;
}
Not working.
jQuery Mobile’s collapsible elements are shown and hidden by toggling
display: noneon the div of the collapsible content. As far as I know, all major browsers disable CSS transitions when thedisplayproperty is changed.An alternative would be overriding the default CSS of jQuery Mobile to always use
display: blockfor the collapsible content div, and then transition on theheightoropacityproperty (depending on whether or not the content needs to be “removed” from the layout).I’ve created this jsFiddle, to demonstrate the transition using the
opacityproperty. It is really just a matter of using the following CSS rules:Transition using the
heightproperty is a little trickier as the content div has no set height. This fiddle does the trick (also see CSS below), but it requires setting a height on the content div. You can change the height toauto, but then the slide down effect doesn’t look quite right in my opinion. Perhaps someone else knows a better method.