Home  >  Q&A  >  body text

javascript - How to implement variable height animation?

How to implement an animation with a variable height of p? For example, if a p is display:none, when a button is clicked, it will be displayed, and the height will gradually change from 0 to the maximum height of the p. The answer from Google is to use max-heigth. However, if the max-height setting is unreasonable (either too large or too small), the animation will be unnatural.

我想大声告诉你我想大声告诉你2671 days ago801

reply all(1)I'll reply

  • 学习ing

    学习ing2017-06-26 10:58:12

    The easiest way is to use JQ’s slideUp and slideDown methods.
    The following is the demo I wrote in native.
    https://jsfiddle.net/11wrgm7b/

    reply
    0
  • Cancelreply