<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>彩色进度条</title>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
*, *:before, *:after {
box-sizing: border-box;
}
body{
font-family: "Open sans", Arial, sans-serif;
color: white;
}
#box {
width: 400px;
height: 500px;
margin: 60px auto 0;
}
.bar {
height: 40px;
width: 0;
position: relative;
margin: 0.5rem 0;
border-radius: 4px;
transition: width 1.2s ease-in-out;
}
.a {
background: #14c3a2;
background-image: repeating-linear-gradient(-45deg, #14c3a2, #14c3a2 30px, #22e8c3 30px, #22e8c3 60px);
background-size: 600px 100%;
animation: barberpole 12s linear infinite;
border-bottom: 0.2rem solid #0d7e68;
}
.b {
background: #cf4647;
background-image: repeating-linear-gradient(-45deg, #cf4647, #cf4647 30px, #da6e6f 30px, #da6e6f 60px);
background-size: 600px 100%;
animation: barberpole 12s linear infinite;
border-bottom: 0.2rem solid #9f292a;
}
.c {
background: #eb7b59;
background-image: repeating-linear-gradient(-45deg, #eb7b59, #eb7b59 30px, #f09f87 30px, #f09f87 60px);
background-size: 600px 100%;
animation: barberpole 12s linear infinite;
border-bottom: 0.2rem solid #dd481b;
}
.d {
background: #524656;
background-image: repeating-linear-gradient(-45deg, #524656, #524656 30px, #6d5d72 30px, #6d5d72 60px);
background-size: 600px 100%;
animation: barberpole 12s linear infinite;
border-bottom: 0.2rem solid #2a242c;
}
.f {
background: #595b5a;
background-image: repeating-linear-gradient(-45deg, #595b5a, #595b5a 30px, #727574 30px, #727574 60px);
background-size: 600px 100%;
animation: barberpole 12s linear infinite;
border-bottom: 0.2rem solid #333434;
}
.bar:before{
content: attr(data-skill);
display: block;
position: absolute;
left: 0;
top: 0;
padding: 10px;
height: 40px;
opacity: 0;
transition: opacity 2s 0.6s;
}
@keyframes barberpole {
from {
background-position: 0% 0%;
}
to {
background-position: 600px 0%;
}
}
.bar.active[data-percent="55"] {
width: 55%;
}
.bar.active[data-percent="65"] {
width: 65%;
}
.bar.active[data-percent="75"] {
width: 75%;
}
.bar.active[data-percent="85"] {
width: 85%;
}
.bar.active[data-percent="100"] {
width: 100%;
}
.bar:after {
content: attr(data-percent) "%";
display: block;
position: absolute;
top: 0;
right: 0;
height: 40px;
padding: 10px;
opacity: 0;
transition: opacity 2s 0.6s;
}
.active:before,.active:after{
opacity: 1;
}
</style>
</head>
<body>
<div id="box">
<div class="bar a" data-skill="HTML5" data-percent="100"></div>
<div class="bar b" data-skill="CSS3" data-percent="85"></div>
<div class="bar c" data-skill="jQuery" data-percent="75"></div>
<div class="bar d" data-skill="PHP" data-percent="65"></div>
<div class="bar f" data-skill="MySQL" data-percent="55"></div>
</div>
</body>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript">
(function() {
$(document).ready(function() {
return $(".bar").each(function(i, elem) {
return $(elem).addClass(‘active‘);
});
});
}).call(this);
</script>
</html>