Animated Preloader With SVG Animation
Tags: html, css, beginners, tutorial
Published: 2021-01-31 05:40:35

***Hello, guys in this <a href="https://blog.stackfindover.com/category/tutorials/" rel="dofollow">tutorial</a> we will create an animated loader with SVG animation (Triangle loading animation using HTML and CSS)***

####What is Page Preloader?####
Essentially, <a href="http://blogs.stackfindover.com/youtube-loading-animation-using-html-and-css/" rel="dofollow">preloaders</a> (also known as loaders) are what you see on the screen while the rest of the content on the page continues to load. Preloaders are often simple or complex animations that are used to entertain visitors during the termination of server operations.

First, we need to create two files ***index.html*** and ***style.css*** then we need to do code for it.

###Triangle Loader Step:1###
***Add below code inside index.html***
```html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Triangle loading Animation</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <link rel="stylesheet" href="style.css" />
    <link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@500&display=swap" rel="stylesheet">
  </head>
  <body>
    <div class="loading_outer">
      <div class="loader-svg">
        <div class="top">
          <svg width="75px" height="75px" viewBox="-4 -1 38 28">
            <polygon fill="transparent"
                     stroke = "#fff"
                     stroke-width="2"
                     points="15,0 30,30 0,30">
            </polygon>
          </svg>
        </div>
        <div class="mid">
          <svg width="150px" height="150px" viewBox="-4 -1 38 28">
            <polygon fill="transparent"
                     stroke = "#fff"
                     stroke-width="2"
                     points="15,0 30,30 0,30">
            </polygon>
          </svg>
        </div>
        <div class="bot">
          <svg width="75px" height="75px" viewBox="-4 -1 38 28">
            <polygon fill="transparent"
                     stroke = "#fff"
                     stroke-width="2"
                     points="15,0 30,30 0,30">
            </polygon>
          </svg>
        </div>
      </div>
      <div class="loader-text">Loading<span>...</span></div>
    </div>
  </body>
</html>
```
###Triangle Loader Step:2###
Then we need to add code for ***style.css*** which code I provide in the below screen.

```css
* {
  padding: 0;
  margin: 0;
  outline: 0;
  color: #fff;
  font-family: 'IBM Plex Sans', sans-serif;
}
body {
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    width: 100vw; 
    overflow: hidden;
}
.loader-svg {
    display: flex;
    align-items: flex-end;
}
.loader-svg .mid svg polygon {
    stroke-dasharray: 50;
    animation: midanim 2.5s linear infinite;
}
@keyframes midanim {
  to {
    stroke-dashoffset:100; 
  }
}
.loader-svg svg polygon {
    stroke-dasharray: 25;
    animation: anim 2s linear infinite;
}
@keyframes anim {
  to {
    stroke-dashoffset:100; 
  }
}
.loader-text {
    text-align: center;
    font-size: 50px;
    text-transform: uppercase;
    margin: 20px 0;
    color: transparent;
    -webkit-text-stroke: 0.5px #fff;
}
.loader-text span {
  color: transparent;
    -webkit-text-stroke: 0.5px #fff;
    animation: dash 1.5s infinite;
}
@keyframes dash {
  from {
    -webkit-text-stroke: 0.5px #fff;
  }
  to {
    color: #fff;
  } 
}
```
###Triangle Loader Video Output:###
{% youtube xhhKHhkKBKs %}

###Triangle Loader CodePen Output:###
{% codepen https://codepen.io/stack-findover/pen/ExNVmjN default-tab=css,result %}