diff --git a/css/creative.css b/css/creative.css index bce1b98..b373bda 100644 --- a/css/creative.css +++ b/css/creative.css @@ -471,6 +471,26 @@ img::-moz-selection { background: 0 0; } +#myBtn { + display: none; /* Hidden by default */ + position: fixed; /* Fixed/sticky position */ + bottom: 20px; /* Place the button at the bottom of the page */ + right: 30px; /* Place the button 30px from the right */ + z-index: 99; /* Make sure it does not overlap */ + border: none; /* Remove borders */ + outline: none; /* Remove outline */ + background-color: #f05f40; /* Set a background color */ + color: white; /* Text color */ + cursor: pointer; /* Add a mouse pointer on hover */ + padding: 15px; /* Some padding */ + border-radius: 10px; /* Rounded corners */ +} + +#myBtn:hover { + background-color: #555; /* Add a dark-grey background on hover */ +} + + body { webkit-tap-highlight-color: #222; -} \ No newline at end of file +} diff --git a/index.html b/index.html index aca8b5e..5157c4d 100644 --- a/index.html +++ b/index.html @@ -245,16 +245,16 @@
Any Questions? Ping us anytime and we'd love to help you
- - + + + diff --git a/js/creative.js b/js/creative.js index 2a38861..492f2f8 100644 --- a/js/creative.js +++ b/js/creative.js @@ -46,3 +46,20 @@ new WOW().init(); })(jQuery); // End of use strict +// Top button +// When the user scrolls down 20px from the top of the document, show the button +window.onscroll = function() {scrollFunction()}; + +function scrollFunction() { + if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) { + document.getElementById("myBtn").style.display = "block"; + } else { + document.getElementById("myBtn").style.display = "none"; + } +} + +// 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 +}