Hi folks, In this tutorial, we will create a loading shimmer effect with pure CSS. First of all, we should know about the loading shimmer. When we loading any data from any server, we have to send a request to the server for the required data. After that server read the request and send data according to the request. To reading the request and collecting data for the request the server will take some time. In between this process, our window screen will be blank. At that time we can show the loading shimmer to the user. When the user will show the loading shimmer he/she can imagine that something is loading and he can wait for the time.
Now let's learn how to create a loading shimmer with plain HTML and CSS.
Live Demo:
HTML:
<div class="card animated-background">
<div class="background-masker line-one-third"></div>
<div class="background-masker line-full"></div>
<div class="background-masker line-one-forth"></div>
<div class="background-masker line-full"></div>
<div class="background-masker line-full"></div>
<div class="background-masker line-full"></div>
<div class="background-masker line-full"></div>
<div class="background-masker line-full"></div>
</div>
CSS:
.card {
border: 15px solid #fff;
margin: 10px;
box-shadow: 0 1px 1px 0 rgba(0,0,0,.05),
0 1px 2px 0 rgba(0,0,0,.1),
0 2px 20px 0 rgba(0,0,0,.2);
}
.animated-background {
animation-duration: 1s;
animation-fill-mode: forwards;
animation-iteration-count: infinite;
animation-name: shimmer;
animation-timing-function: linear;
background: #f6f7f8;
background: linear-gradient(to right, #e5e5e5 8%, #f5f5f5 18%, #e5e5e5 33%);
background-size: 800px 104px;
height: 130px;
position: relative
}
@keyframes shimmer {
0% {
background-position: -200px 0
}
100% {
background-position: 468px 0
}
}
.background-masker {
height: 10px;
background: #fff;
}
.background-masker:nth-child(n+4):not(:last-child) {
margin-bottom: 10px;
}
.background-masker.line-one-third {
width: 30%;
margin-left: 70%;
}
.background-masker.line-one-forth {
width: 20%;
margin-left: 80%;
}
.background-masker.full {
width: 100%;
}
Live Demo:



























