သုံးပါးလည့်ကြည့်ပါ - လျားချိန်ညွှန်းကြည့်ပါ
သုံးပါးလည့်ကြည့်ပါ - လျားချိန်ညွှန်းကြည့်ပါ
သုံးပါးလည်းကြည့်ပါ - လျားချိန်ညွှန်းကြည့်ပါ
ပထမပိုင်း - ဟိုတယ်ကိုထပ်ပေးပါ
<div class="header"> <h2>Scroll Indicator</h2> <div class="progress-container"> <div class="progress-bar" id="myBar"></div> </div> </div> <div>content...</div>
ဒုတိယပိုင်း - ဖျော်ဖြေကိုထပ်ပေးပါ
/* 设置标题样式:固定位置(始终保持在顶部) */ .header { position: fixed; top: 0; z-index: 1; width: 100%; background-color: #f1f1f1; } /* 进度容器(灰色背景) */ .progress-container { width: 100%; height: 8px; background: #ccc; } /* 进度条(滚动指示器) */ .progress-bar { height: 8px; background: #04AA6D; width: 0%; }
တတိယပိုင်း - ဂျာမည်းကိုထပ်ပေးပါ
// 当用户滚动页面时,执行 myFunction window.onscroll = function() {myFunction()}; function myFunction() { var winScroll = document.body.scrollTop || document.documentElement.scrollTop; var height = document.documentElement.scrollHeight - document.documentElement.clientHeight; var scrolled = (winScroll / height) * 100; document.getElementById("myBar").style.width = scrolled + "%"; }