我只是想让下面代码的动画在用户滚动到页面的那个部分时变得活动起来。这只需要发生一次,直到页面刷新,动画可以再次发生。
<ul class="skill-list">
<li class="skill">
<h3>Nunchucks</h3>
<progress class="skill-1" max="100" value="50">
<strong>Skill Level: 50%</strong>
</progress>
</li>
<li class="skill">
<h3>Bow Staff</h3>
<progress class="skill-2" max="100" value="75">
<strong>Skill Level: 75%</strong>
</progress>
</li>
<li class="skill">
<h3>Roundhouse Kick</h3>
<progress class="skill-3" max="100" value="25">
<strong>Skill Level: 25%</strong>
</progress>
</li>
</ul>下面是CSS:
<!-- skill chart -->
body {
font-family: 'Open Sans', sans-serif;
padding: 2em;
}
h1 {
font-size: 2em;
font-weight: 800;
}
h3 {
font-size: 2em;
}
progress, progress[role] {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
border: none;
background-size: auto;
height: 100px;
width: 100%;
}
.skill-list {
list-style: none;
margin: 0;
padding: 1em;
}
.skill {
margin-bottom: 1em;
position: relative;
}
.skill h3 {
color: #fff;
left: 1em;
line-height: 1;
position: absolute;
top: 1em;
}
.skill ::-webkit-progress-value {
-webkit-animation: bar-fill 2s;
width: 0px;
}
.skill-1::-webkit-progress-value {
background: #ff9e2c;
}
.skill-1::-moz-progress-bar {
background: #ff9e2c;
}
.skill-2::-webkit-progress-value {
background: #4ecdc4;
}
.skill-2::-moz-progress-bar {
background: #4ecdc4;
}
.skill-3::-webkit-progress-value {
background: #ff6b6b;
}
.skill-3::-moz-progress-bar {
background: #ff6b6b;
}
@-webkit-keyframes bar-fill {
0% {
width: 0;
}
}
@keyframes bar-fill {
0% {
width: 0;
}
}发布于 2015-03-03 07:15:44
您需要一个可以跟踪滚动位置的脚本,这里是wow.js
https://stackoverflow.com/questions/28821160
复制相似问题