0

I'm trying to make an animation that involves the height property. But the animation only works if the initial height property is set, if not it the animation won't work.

This will work:

.my-class {
    height: 20px;
}

.my-class:hover {
    height: 560px;
}

This wont:

.my-class {
}

.my-class:hover {
    height:560px;
}

And I dont want to give it an initial height. How can I make it work?

Golan Kiviti
  • 3,895
  • 7
  • 38
  • 63
  • 1
    Possible duplicate of [How can I transition height: 0; to height: auto; using CSS?](http://stackoverflow.com/questions/3508605/how-can-i-transition-height-0-to-height-auto-using-css) – Aziz Aug 14 '16 at 12:18
  • This has already been answered here: http://stackoverflow.com/a/8331169/877671 – Aziz Aug 14 '16 at 12:19
  • Use max-height instead of height – SumanKalyan Aug 14 '16 at 14:11

0 Answers0