कैसे बनाएं: सरकार इंडिकेटर
- पिछला पृष्ठ कालक्रम
- अगला पृष्ठ प्रगति पट्टी
CSS और JavaScript का उपयोग करके सरकार इंडिकेटर बनाने को सीखें。
सरकार इंडिकेटर कैसे बनाएं
पहला कदम - HTML जोड़ें:
<div class="header"> <h2>Scroll Indicator</h2> <div class="progress-container"> <div class="progress-bar" id="myBar"></div> </div> </div> <div>content...</div>
दूसरा कदम - CSS जोड़ें:
/* शीर्षक शैली सेट करें: फ़िक्स्ड स्थिति (हमेशा शीर्ष पर) */ .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%; }
तीसरा कदम - JavaScript जोड़ें:
// जब उपयोगकर्ता पृष्ठ को सरकार करता है, तो 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 + "%"; }
- पिछला पृष्ठ कालक्रम
- अगला पृष्ठ प्रगति पट्टी