JSFiddle - React, Tailwind, and code Playground
by Cone
HTML
<div class="demo2">
<h1>animated progress bar <br /><small>in 4 lines of jquery</small></h1>
<div id="progressBar" class="default">
<div></div>
</div> <span class="img">
<img src="https://www.planwallpaper.com/static/images/thumb-1920-171916.jpg" />
<img src="http://www.usabobbers.com/wp-content/uploads/2012/01/Yamaha-XS650-Lime-Green-Bobber-Motorcycle.jpeg?1371143501" />
<img src="http://wallpoper.com/images/00/38/49/40/american-cars_00384940.jpg?1371143501" />
<img src="http://wallpoper.com/images/00/26/14/38/cars-saleen_00261438.jpg?1371143501" />
</span>
CSS
#progress {
max-width:600px;
min-width:300px;
height:25px;
display:table;
border:1px solid #dfdfdf;
background:#f4f4f4;
}
#progressBar {
margin-left: 100px;
width: 400px;
height: 22px;
}
#progressBar div {
height: 100%;
color: #fff;
text-align: right;
font-size: 12px;
line-height: 22px;
width: 0;
}
.default {
background: #292929;
border: 1px solid #111;
border-radius: 5px;
overflow: hidden;
box-shadow: 0 0 5px #333;
}
.default div {
background-color: cyan;}
#page {
margin: 0 auto;
width: 600px;
}
a {
color: #777;
text-decoration: none;
display: inline-block;
}
a:hover {
color: #333;
}
.bar {
background-color: #f4f4f4;
color: #333;
box-shadow: 0px 0px 2px #333;
line-height: 22px;
padding: 2px 20px 0;
font-family:'Josefin Sans', sans-serif;
font-weight: 400;
font-size: 13px;
overflow: hidden;
}
.bar:hover {
opacity: 1;
}
.bar a {
color: #333;
}
.bar a:hover {
color: #000;
text-decoration: underline;
}
h1 {
padding: 0;
margin: 60px 0 60px;
color: #282828;
font-family:'Josefin Sans', sans-serif;
font-weight: 400;
text-align: center;
font-size: 45px;
line-height: 40px;
text-align: center;
}
p {
font-size: 20px;
font-family:'Josefin Sans', sans-serif;
line-height: 26px;
}
.steps {
margin: 20px 0;
text-align: center;
}
.steps a {
padding: 3px 0px;
margin: 0 10px;
text-decoration: none;
font-size: 15px;
color: #777;
}
.steps a:hover {
color: #111;
}
small {
font-weight: 100;
}
#ad {
width: 468px;
padding: 5px 5px 0 5px;
background-color: #e3e3e3;
float: left;
box-shadow: 0 0 3px #999;
margin-top: 30px;
margin-left: 61px;
margin-bottom: 20px;
}
p {
float: left;
margin: 0;
}
.active {
color: #000 !important;
border-bottom: 3px solid #000;
}
#types {
text-transform: uppercase;
...
JavaScript
function progressBar(percent, $element) {
var progressBarWidth = percent * $element.width() / 100;
$element.find('div').animate({ width: progressBarWidth }, 500).html(percent + "% Progress ");
};
var numberOfImages = $('.img img').length,
numberOfLoaded = 0,
step = 100 / numberOfImages;
$('.img img').each(function (i, item) {
$(item).load(function () {
numberOfLoaded++;
progressBar(step * numberOfLoaded, $('#progressBar'));
});
});