leo giovanni
leo giovanni

Reputation: 61

How to conditionally expand element according to height of its content in ionic?

I want to expand my element conditionally, so that on click it will expand according to height of its content.

Component's html:

<div class="container"  [style.height]="enlarged === true ? '120px' : '50px'">
  <div class="textContainer">
    <ion-label>
      Welcome    </ion-label>
   <ion-label>{{ content}}</ion-label>
 </div>
</div>

Upvotes: 0

Views: 142

Answers (1)

H S W
H S W

Reputation: 7119

It can be done by using auto. Such as:

 [style.height]="enlarged === true ? 'auto' : '50px'"

Upvotes: 1

Related Questions