Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS transition not working with max-height: fit-content

Tags:

css

I'm trying to animate some expansible panel with a CSS like this:

.panel {
  transition: max-height 0.1s ease-in-out;
  flex: 90;
  max-height: 26px;

  &.expanded {
    max-height: fit-content;
  }
}

Problem is this transition is not working. If I use some numeric max-height value in .expanded, it works perfect.

Any idea?

I read that fit-content, max-content, ... are not animatable. Is that the case?

like image 663
agascon Avatar asked Oct 28 '25 22:10

agascon


1 Answers

yes fit-content and max-content are not animate your content. you have to provide some numeric value to the max-height for animate. it consider the height required to your content so you have to provide the value of max-height greater then your content height.

Thank you.

like image 134
KuldipKoradia Avatar answered Oct 30 '25 14:10

KuldipKoradia