<h1>Battle.net <b>style progress bar</b></h1>
<div class="progress">
<b class="progress__bar">
<span class="progress__text">
Progress: <em>0%</em>
</span>
</b>
</div>
@import url(https://fonts.googleapis.com/css?family=Roboto:100italic,100,300italic,300,700italic,700);
$red: #c90414;
$blue: #1287cc;
$green: #00b217;
$yellow: #e89e00;
$orange: #c92f00;
@mixin innerColor( $color: #0db6e0 ) {
background-color: transparentize( $color , 0.05 );
background-image:
linear-gradient(
90deg,
transparentize( lighten( $color, 5% ), 1 ) 10%,
transparentize( lighten( $color, 10% ), 0.2 ) 30%,
transparentize( lighten( $color, 15% ), 0 ) 70%,
transparentize( lighten( $color, 10% ), 0.2 ) 80%,
transparentize( lighten( $color, 5% ), 1 ) 90%
),
linear-gradient(
to right,
transparentize( lighten( $color, 15% ), 1 ) 0%,
transparentize( lighten( $color, 15% ), 0 ) 100%
),
linear-gradient(
to left,
transparentize( lighten( $color, 15% ), 1 ) 0%,
transparentize( lighten( $color, 15% ), 0 ) 100%
);
border-color: lighten( $color, 20% );
box-shadow:
0 0 0.6em lighten( $color, 10% ) inset,
0 0 0.4em lighten( $color, 5% ) inset,
0 0 0.5em transparentize( $color, 0.5),
0 0 0.1em transparentize( lighten( $color, 50% ), 0.5);
}
.progress {
font-size: 1.2em;
height: 20px;
background: rgba(255,255,255,0.05);
border-radius: 2px;
border: 1px solid rgba(255,255,255,0.2);
&--active .progress__bar {
opacity: 1;
}
&__text {
width: 20em;
padding: 0 0.9em;
position: absolute;
em {
font-style: normal;
}
}
&__bar {
color: white;
font-size: 12px;
font-weight: normal;
text-shadow: 0 1px 1px rgba(0,0,0,0.6);
line-height: 19px;
display: block;
position: relative;
top: -1px;
left: -1px;
width: 0%;
height: 100%;
opacity: 0;
border: 1px solid;
border-radius: 2px 0 0 2px;
background-size: 100px 30px, 130px 30px, 130px 30px;
background-position: -20% center, right center, left center;
background-repeat: no-repeat, no-repeat, no-repeat;
transition:
opacity 0.2s ease,
width 0.8s ease-out,
background-color 1s ease,
border-color 0.3s ease,
box-shadow 1s ease;
animation: pulse 2s ease-out infinite;
@include innerColor($red);
&--orange {
@include innerColor($orange);
}
&--yellow {
@include innerColor($yellow);
}
&--green {
@include innerColor($green);
}
&--blue {
@include innerColor($blue);
}
&:before,
&:after {
content: "";
position: absolute;
right: -1px;
top: -10px;
width: 1px;
height: 40px;
}
&:before {
width: 7px;
right: -4px;
background:
radial-gradient(
ellipse at center,
rgba(255,255,255,0.4) 0%,
rgba(255,255,255,0) 75%
);
}
&:after {
background:
linear-gradient(
to bottom,
rgba(255,255,255,0) 0%,
rgba(255,255,255,0.3) 25%,
rgba(255,255,255,0.3) 75%,
rgba(255,255,255,0) 100%
);
}
}
&--complete {
.progress__bar {
animation: none;
border-radius: 2px;
&:after,
&:before {
opacity: 0;
}
}
}
}
@keyframes pulse {
0% {
background-position: -50% center, right center, left center;
}
100% {
background-position: 150% center, right center, left center;
}
}
body, html {
color: white;
padding: 20px 50px;
background: rgb(19,28,35);
font-family: Roboto;
}
h1 { font-weight: 900; line-height: 1em; margin: 0.5em 0; }
h1 b { font-weight: 100; }
View Compiled
var $progress = $(".progress"),
$bar = $(".progress__bar"),
$text = $(".progress__text"),
percent = 0,
update,
resetColors,
speed = 1000,
orange = 30,
yellow = 55,
green = 85,
timer;
resetColors = function() {
$bar
.removeClass("progress__bar--green")
.removeClass("progress__bar--yellow")
.removeClass("progress__bar--orange")
.removeClass("progress__bar--blue");
$progress
.removeClass("progress--complete");
};
update = function() {
timer = setTimeout( function() {
percent += Math.random() * 1.8;
percent = parseFloat( percent.toFixed(1) );
$text.find("em").text( percent + "%" );
if( percent >= 100 ) {
percent = 100;
$progress.addClass("progress--complete");
$bar.addClass("progress__bar--blue");
$text.find("em").text( "Complete" );
} else {
if( percent >= green ) {
$bar.addClass("progress__bar--green");
}
else if( percent >= yellow ) {
$bar.addClass("progress__bar--yellow");
}
else if( percent >= orange ) {
$bar.addClass("progress__bar--orange");
}
speed = Math.floor( Math.random() * 1000 );
update();
}
$bar.css({ width: percent + "%" });
}, speed);
};
setTimeout( function() {
$progress.addClass("progress--active");
update();
},1000);
$(document).on("click", function(e) {
percent = 0;
clearTimeout( timer );
resetColors();
update();
});
This Pen doesn't use any external CSS resources.