ionic-frameworkheightresponsiveion-content

ion-content height 100% bigger than screen


I need to build a single page vertically responsive, it needs to be full screen and no scroll.

I've tried doing

ion-content: {
  height: 100%;
}

and many other possible solutions but nothing seems to work.

I've found that in small devices like iPhone SE the height of the ion-content is bigger than the screen of the device or the ion-content goes below the ion-tabs.

This is my problem (iPhone SE)

This is how i want it to look like (iPhone X)

Here is the ion-content:

<ion-content>
  <ion-grid>
    <ion-row>
      <ion-col size="12">
        <p *ngIf="![null, undefined, 'null', 'undefined'].includes(user_type)" class="user-type">{{user_type_text}}</p>
      </ion-col>
    </ion-row>

    <ion-row>
      <ion-col size="12">
        <ion-icon name="person-circle" class="avatar"></ion-icon>
      </ion-col>
    </ion-row>

    <ion-row>
      <ion-col size="12">
        <p>{{user_name}}</p>
      </ion-col>
    </ion-row>
    
    <ion-row class="work-status">
      <ion-col size="4">
        <p class="work-status-label">Pending</p>
        <p class="work-status-value" [style.color]="color_theme">{{pending}}</p>
      </ion-col>
      <ion-col size="4">
        <p class="work-status-label">In Progress</p>
        <p class="work-status-value" [style.color]="color_theme">{{progress}}</p>
      </ion-col>
      <ion-col size="4">
        <p class="work-status-label">Completed</p>
        <p class="work-status-value" [style.color]="color_theme">{{completed}}</p>
      </ion-col>
    </ion-row>
    
    <ion-row>
      <ion-col size="6">
        <ion-card (click)="profile()">
          <ion-icon name="person-circle" class="btn-icon" [style.color]="color_theme"></ion-icon>
          <p class="btn-text">My Profile</p>
        </ion-card>
      </ion-col>
      <ion-col size="6">
        <ion-card (click)="notifications()">
          <ion-icon name="notifications" class="btn-icon" [style.color]="color_theme"></ion-icon>
          <p class="btn-text">Notifications</p>
        </ion-card>
      </ion-col>
    </ion-row>

    <ion-row>
      <ion-col size="6">
        <ion-card (click)="requests()">
          <ion-icon [name]="request_button_icon" class="btn-icon" [style.color]="color_theme"></ion-icon>
          <p class="btn-text">{{request_button_text}}</p>
        </ion-card>
      </ion-col>
      <ion-col size="6">
        <ion-card (click)="explore()">
          <ion-icon name="search" class="btn-icon" [style.color]="color_theme"></ion-icon>
          <p class="btn-text">{{explore_button_text}}</p>
        </ion-card>
      </ion-col>
    </ion-row>

  </ion-grid>
</ion-content>

Here is the scss:

ion-grid {
  height: 100%;
}

ion-content {
  height: 100%;
}

p {
  text-align: center;
}

.user-type {
  margin: 0;
}

.avatar {
  font-size: 500%;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.work-status{
  -webkit-box-shadow: 0px 10px 20px -10px rgba(0,0,0,0.75);
  -moz-box-shadow: 0px 10px 20px -10px rgba(0,0,0,0.75);
  box-shadow: 0px 10px 20px -10px rgba(0,0,0,0.75);
  margin-left: 5%;
  margin-right: 5%;
  margin-bottom: 5%;
}

.work-status-value {
  margin-bottom: 0;
  margin-top: 0;
  font-size: 250%;
}

.work-status-label {
  margin-bottom: 0;
  margin-top: 0;
}

.btn-text {
  font-size: 150%;
  margin-top: 0;
  margin-left: 2%;
  margin-right: 2%;
}

.btn-icon {
  font-size: 300%;
}

Solution

  • Add this in your CSS:

    ion-card{
      margin-bottom: 10px;
      margin-top: 10px;
    }