Search code examples
ionic-frameworkionic3

How to show ionic spinner in the centre position of the screen?


I have a spinner in my ionic project. I want to put the spinner in the centre position of the screen. But it always shows up in the left top corner as:

enter image description here

Html file is:

<div *ngIf="spinner == 'true'">
   <ion-spinner name="bubbles"></ion-spinner>
</div>

My scss file is:

page-login {
    ion-spinner {
    width: 28px;
    height: 28px;
    stroke: #444;
    fill: #222;
  }
}

Can you help?


Solution

  • I find the solution finally. Add a class spin and set text align center.

    <div class="spin" *ngIf="spinner == 'true'">
        <ion-spinner name="bubbles"></ion-spinner>
    </div>
    
    .spin{
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
     }
     ion-spinner {
        width: 28px;
        height: 28px;
        stroke: #444;
        fill: #222;
     }