<div style="height: 1500px;">
</div>
<div class="progress-container">
<div class="progress-bar" data-progress="90%"><p class="progress-text">Google Ads在Google搜索引擎上覆盖超过90%的互联网用户。</p></div>
<p class="progress-tag">90%</p>
<div class="progress-bar" data-progress="60%"><p class="progress-text">超过2/3的潜在用户会被精准定位的Google Ads付费广告所吸引,点进进入。</p></div>
<p class="progress-tag">2/3</p>
<div class="progress-bar" data-progress="90%"><p class="progress-text">覆盖全球超过200万个网站和应用,可触及到网上90%的互联网用户。</p></div>
<p class="progress-tag">200w+</p>
</div>
<style>
.progress-container {
margin: 50px 0;
}
.progress-bar {
width: 80%;
height: 80px;
background-color: #ffffff;
border-radius: 5px;
/* overflow: hidden; */
position: relative;
margin-bottom: 20px;
display: inline-block;
margin-right: 30px;
}
.progress-bar::before {
content: '';
position: absolute;
left: 0;
top: 0;
height: 100%;
width: var(--progress-width, 0); /* 使用CSS变量 */
background-color: #000000;
transition: width 2s ease;
border-radius: 5px 0 0 5px;
}
.progress-text{
position: relative;
z-index: 1;
margin: 0;
line-height: 30px;
font-size: 16px;
white-space: normal;
color: #ffffff;
width: 55%;
text-align: left;
margin-top: 10px;
margin-left: 15px;
}
.progress-tag{
width: 80px;
height: 80px;
padding: 20px;
font-weight: 700;
display: inline-block;
margin: 0;
border-radius: 50%;
color: #ffffff;
background-color: #000000;
text-align: center;
line-height: 40px;
margin-bottom: 20px;
}
@media screen and (max-width:768px) {
.progress-container {
margin: 50px 10px;
}
.progress-bar {
width: 68%;
margin-right: 20px;
}
.progress-text {
line-height: 18px;
font-size: 12px;
width: 55%;
}
.google-six-content ul li h3 {
width: 150px;
height: 150px;
line-height: 130px;
}
}
</style>
<script>
document.addEventListener('DOMContentLoaded', function() {
var progressBars = document.querySelectorAll('.progress-bar');
document.addEventListener('scroll', function() {
var windowHeight = window.innerHeight;
progressBars.forEach(function(bar) {
var rect = bar.getBoundingClientRect();
if (rect.top < windowHeight) {
var progress = bar.getAttribute('data-progress');
bar.style.setProperty('--progress-width', progress);
}
});
});
});
</script>
标签:bar,填充,进度条,color,js,width,progress,height,margin
From: https://blog.csdn.net/p_s_p/article/details/141399781