Categories: Snippets

Pure CSS Page Loader in website

preloader or what some call a loading screen — is the what you see on some sites before the main content of the web page is loaded.

.page-loader{
    position: fixed;
    z-index: 200;
    width: 100%;
    height: 100%;
    top:0;
    left:0;
    background: #fff;
    display: block;  
    
}
.page-loader .fa{
    font-size: 2.5rem;
}
.page-loader,
.page-loader.visible{
    -webkit-transition: 0.6s;
    -ms-transition: 0.6s;
    -moz-transition: 0.6s;
    transition: 0.6s;
    opacity: 1;
    visibility: visible;    
}
.page-loader.p-hidden{
    visibility: hidden;
    opacity: 0;
}
    .page-loader div{
        position: absolute;
        top:50%;
        width: 100%;
        text-align: center;
        color: #1d1d1d;
        margin-top: -50px;
     display: block; 
    }
  .page-loader div .icon{
   display: inline-block;
   margin-left: -20px;
            left: 50%;
   width: 40px;
   height: 40px;
   content: "";
   background: #1d1d1d;
   border-radius: 100px;
   border: 8px solid #fff;
   border-top-color: rgba(255, 255, 255, 0.58);
   border-bottom-color: rgba(255, 255, 255, 0.58);
  }
        .page-loader div p{
            margin-top: 100px;
            font-size: 14px;
            color: #555;
            letter-spacing: 1em;
            padding-left: 1em;
            text-transform: uppercase;
   font-family: 'Roboto', 'Helvetica', sans-serif;
   font-weight: bold;
        }

.ion-spin, .ion-loading-a, .ion-loading-b, .ion-loading-c, .ion-loading-d, .ion-looping, .ion-refreshing, .ion-ios7-reloading {
    -webkit-animation: spin 1s infinite linear;
    -moz-animation: spin 1s infinite linear;
    -o-animation: spin 1s infinite linear;
    animation: spin 1s infinite linear;
}
@keyframes spin {
    from {
        transform:rotate(0deg);
    }
    to {
        transform:rotate(360deg);
    }
}

HTML

<div class="page-loader" id="page-loader">
    <div>
      <div class="icon ion-spin"></div>
      <p>loading</p>
    </div>
  </div>

Recent Posts

Customize the Browser’s Scrollbar only with CSS

-webkit-scrollbar consists of seven different pseudo-elements, and together comprise a full scrollbar UI element: ::-webkit-scrollbar the background…

6 years ago

Fix iOS bug not displaying 100vh correctly

There are many Javascript fixes for the viewport height units bug in iOS 7 (iPhone…

7 years ago

Create responsive websites with CSS3 media query

Responsive web design (RWD) is an approach whereby a designer creates a web page that…

7 years ago