The problem
You need to display progress or loading status with an attractive animated bar.
The solution
.progress-container {
width: 100%;
height: 8px;
background: #1a1a2e;
border-radius: 4px;
overflow: hidden;
}
.progress-bar {
height: 100%;
background: linear-gradient(90deg, #3a7bff, #8b5cf6);
border-radius: 4px;
transition: width 0.5s ease;
}
/* Striped animated progress */
.progress-bar-striped {
height: 100%;
background: repeating-linear-gradient(
45deg,
#3a7bff,
#3a7bff 10px,
#5a8eff 10px,
#5a8eff 20px
);
background-size: 200% 100%;
animation: progress-stripes 1s linear infinite;
border-radius: 4px;
}
@keyframes progress-stripes {
0% { background-position: 0 0; }
100% { background-position: 40px 0; }
}
/* Indeterminate loading */
.progress-indeterminate {
width: 30%;
animation: progress-slide 1.5s ease-in-out infinite;
}
@keyframes progress-slide {
0% { margin-left: 0; }
50% { margin-left: 70%; }
100% { margin-left: 0; }
}See it live
Put it to work
<!-- Standard progress -->
<div class="progress-container">
<div class="progress-bar" style="width: 65%"></div>
</div>
<!-- Animated striped -->
<div class="progress-container">
<div class="progress-bar-striped" style="width: 80%"></div>
</div>
<!-- Indeterminate loading -->
<div class="progress-container">
<div class="progress-bar progress-indeterminate"></div>
</div>Worth knowing
Set width dynamically with JavaScript for actual progress. Use indeterminate for unknown durations.