Difference between revisions of "Template:NAWI Graz:navbar"

Line 62: Line 62:
 
}, 20);
 
}, 20);
  
 +
// back to top// When the user scrolls down 20px from the top of the document, show the button
 +
window.onscroll = function() {scrollFunction()};
  
    </script>
+
function scrollFunction() {
      
+
     if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
 
+
        document.getElementById("myBtn").style.display = "block";
 
+
    } else {
 
+
        document.getElementById("myBtn").style.display = "none";
 
+
    }
<style>
+
/* dropdown on hover */
+
.dropdown:hover>.dropdown-menu {
+
  display: block;
+
 
}
 
}
  
 +
// When the user clicks on the button, scroll to the top of the document
 +
function topFunction() {
 +
    document.body.scrollTop = 0; // For Chrome, Safari and Opera
 +
    document.documentElement.scrollTop = 0; // For IE and Firefox
 +
} button
  
#rider {
+
    </script>
    position: relative;
+
   
}
+
</style>
+
 
+
  
 
     <!--- THIS IS WHERE THE HTML BEGINS -->
 
     <!--- THIS IS WHERE THE HTML BEGINS -->
Line 169: Line 169:
 
         </nav>
 
         </nav>
 
</div>
 
</div>
 +
 +
<button onclick="topFunction()" id="topBtn" title="Go to top">Go to Top</button>
  
 
     <!-- start of content -->
 
     <!-- start of content -->
  
 
     </html>
 
     </html>

Revision as of 13:11, 31 October 2017