Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expand/collapse div with animation and non fixed size

http://embed.plnkr.co/tcTZlA/preview

Basically all I want is not having to set the height in the .slideDown class. I want it to expand based on the height of the content of the div. I didn't find how to do this the AngularJS way so if you have any clue I'll take it.

Thank you

like image 808
dkx22 Avatar asked Dec 15 '16 12:12

dkx22


2 Answers

.slideDown {
  height:141px;
  transition:height 0.35s ease;
  overflow:hidden;
  position:relative;
}

In this class remove height property then it will become non fixed size like this

try this

   .slideDown.ng-hide {
  max-height: 0;
  transition: max-height 0.35s ease-out;
  overflow:hidden;
  position:relative;
}

.slideDown {
  max-height: 1000px;
 transition: max-height 0.35s ease;
  overflow:hidden;
  position:relative;
}
like image 192
Suresh B Avatar answered Nov 14 '22 22:11

Suresh B


work with max-height property not height

.slideDown.ng-hide {
  max-height:0;
  transition:max-height 0.35s ease;
  overflow:hidden;
  position:relative;
}

.slideDown {
  max-height:400px; // make this value higher than the expected content value 
  transition:max-height 0.35s ease;
  overflow:hidden;
  position:relative;
}
like image 29
Ahmed Mostafa Avatar answered Nov 15 '22 00:11

Ahmed Mostafa