Search code examples
cssangularjsionic-frameworkionic4

Ionic how to align ion-content to bottom of page


I'm trying to align a message input box to the bottom of the page, but I can't seem to get it working. I've tried using align-self-end and making a css class for ion-footer.

<ion-content>
<ion-footer align-self-end>
  <ion-toolbar color="light">
    <ion-row align-self-end>
      <ion-col size="10">
        <ion-textarea auto-grow class="message-input" rows="1" [(ngModel)]="message"></ion-textarea>
      </ion-col>
      <ion-col size="2">
        <ion-button expand="block" fill="clear" color="primary" [disabled]="message === ''" class="msg-btn"
          (click)="sendMessage()">
          <ion-icon name="paper-plane"></ion-icon>
        </ion-button>
      </ion-col>
    </ion-row>
  </ion-toolbar>
</ion-footer> 
</ion-content>
ion-footer{
    display: flex;
    align-items: flex-end;
    margin: auto; 
    padding-top: .5em;
    padding-bottom: .5em;
  }

Solution

  • <ion-footer> is not meant to go inside <ion-content>

    The structure of html file should be

    <ion-header>
    </ion-header>
    
    <ion-content>
    </ion-content>
    
    <ion-footer>
    </ion-footer>
    

    In your case you want to show another element towards the bottom of the content, you can insert textarea like this..Do not put ion-row inside the ion-toolbar.

    <ion-content>
    </ion-content>
    
    
    <ion-footer>
        <ion-toolbar>
            <ion-textarea maxRows="4" [(ngModel)]="message" placeholder="Write a message"></ion-textarea>
            <ion-icon name="paper-plane" slot="end"></ion-icon>
        </ion-toolbar>
    </ion-footer>