Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

centering preloader in materialize

Given this :

I want to use this Preloader with position:fixed and centered.So what i did was:

.loader {
  position:fixed;
  top:50%;
  left:50%;
  -webkit-transform:translate(-50%,-50%);
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.6/css/materialize.min.css">
<body>
  <div class="preloader-wrapper big active loader">
    <div class="spinner-layer spinner-blue-only">
      <div class="circle-clipper left">
        <div class="circle"></div>
      </div><div class="gap-patch">
        <div class="circle"></div>
      </div><div class="circle-clipper right">
        <div class="circle"></div>
      </div>
    </div>
  </div>
</body>

which causes an animation :-/

like image 241
greedsin Avatar asked Nov 04 '16 09:11

greedsin


Video Answer


2 Answers

As long as your container has a declared width and height this will center the element horizontally and vertically. JSfiddle

.loader {
position: absolute;
top :0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
}
like image 89
Ron.Basco Avatar answered Sep 21 '22 07:09

Ron.Basco


Slightly changed the loader's style which helps to remove the issue of showing scrollbar intermittently

<div className="preloader-wrapper big active loader">
    // spinners
</div>

.loader {
  position: absolute;
  margin: auto;
  top: 50vh;
  bottom: 50vh;
  left: 0;
  right: 0;
}
like image 29
fanngalinga Avatar answered Sep 22 '22 07:09

fanngalinga