Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 678
lei lei Avatar asked Mar 04 '19 23:03

lei lei


2 Answers

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;
 }
like image 58
lei lei Avatar answered Oct 02 '22 19:10

lei lei


Add a class spin and set text align center.

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

.spin{
    text-align: center;
  }
  ion-spinner {
    width: 28px;
    height: 28px;
    stroke: #444;
    fill: #222;
  }
like image 30
Anandh Sp Avatar answered Oct 02 '22 20:10

Anandh Sp