user12075155
user12075155

Reputation:

How to center ionic avatar on a page

I am trying to center the avatar to the middle, with the code below but it doesn't work. I have used this class="ion-align-items-center" that i got from the ionic documents but with no successs.

    <ion-grid style ="text-align: center">
     <ion-row class="ion-align-items-center" >

    <ion-col class="ion-align-items-center" *ngFor="let item of students" >
      <!--   <div  class= "imageHold" >
            <ion-img [src]= "profileImage || item.profileImage"></ion-img>
        </div> -->
        <ion-avatar class="ion-align-items-center">
            <ion-img [src]= "profileImage || item.profileImage"></ion-img>
          </ion-avatar>
    </ion-col>  
   </ion-row >
   <ion-row  style ="text-align: center">  
       <ion-col>
    <ion-button  size="small" fill="outline" (click)="chooseProfilePic()" >Choose Profile Photo</ion-button>
   </ion-col>
   </ion-row>
   </ion-grid>

I get this result

enter image description here

Upvotes: 1

Views: 993

Answers (1)

Miyas Mohammed
Miyas Mohammed

Reputation: 486

add a class in the avatar div.

.avatar{
   margin: auto;
}

Upvotes: 4

Related Questions