我在我的網頁上有一些統計數據,並且在某些網站上看到,在滾動到頁面的那一部分時,可能會使數字達到目標數量。我將如何實現這一目標?滾動的動畫數字計數器
.personality {
width: 100%;
height: 300px;
float: left;
background: rgb(0, 200, 200);
background: rgba(52, 119, 206, 0.7);
background-position: center;
background-size: cover;
background-image: url(../images/25H.jpg);
background-attachment: fixed;
}
.personality-overlay{
width: 100%;
height: 300px;
float: left;
background: rgb(0, 200, 200);
background: rgba(52, 119, 206, 0.7);
background-attachment: fixed;
}
.statsbar {
width: 100%;
height: 100px;
margin-top:120px;
}
.stat-one {
width: 25%;
height: 100px;
float:left;
}
.stat-two {
width: 25%;
height: 100px;
float:left;
}
.stat-three {
width: 25%;
height: 100px;
float:left;
}
.stat-four {
width: 25%;
height: 100px;
float:left;
}
.stat-number {
width: 100%;
height: 50px;
float:left;
text-align:center;
color:#FFF;
font-size: 60px;
font-weight: 100;
text-transform: uppercase;
color:#FFF;
}
.stat-title {
width: 100%;
height: 50px;
float:left;
text-align:center;
color:#FFF;
font-size: 14px;
font-weight: 100;
text-transform: uppercase;
color:#FFF;
}
<div class="personality">
<div class="personality-overlay">
<div class="statsbar">
<div class="stat-one">
<div class="stat-number">200</div>
<div class="stat-title">CUPS OF TEA A DAY</div>
</div>
<div class="stat-two">
<div class="stat-number">60</div>
<div class="stat-title">MINIMUM HOURS OF SLEEP A WEEK</div>
</div>
<div class="stat-three">
<div class="stat-number">10</div>
<div class="stat-title">CUPS OF TEA A DAY</div>
</div>
<div class="stat-four">
<div class="stat-number">10%</div>
<div class="stat-title">HOURS SLEEP A WEEK</div>
</div>
</div>
</div>
</div>
Jfiddle - https://jsfiddle.net/dr8g1gop/
_「可能使數字達到目標數字。」_哪個數字? 「數」到什麼目標數字? – guest271314
每個人從0開始計數到顯示的數字,例如0 - 20? – iamdanmorris
「每一個」什麼是「一個」? – guest271314