1. Before </head> Tag
<style>
#myBtn {
display: none;
position: fixed;
bottom: 20px;
right: 30px;
z-index: 99;
font-size: 18px;
border: 5;
outline: none;
background-color: blue;
color: white;
cursor: pointer;
padding: 15px;
border-radius: 30px;
}
#myBtn:hover {
background-color: #555;
}
</style>
2. Before </body> Tag
<a href="tel:mobile number"><button id="myBtn" title="Calling Feature">Call Us</button></a>
<script>
//Get the button
var mybutton = document.getElementById("myBtn");
// 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) {
mybutton.style.display = "block";
} else {
mybutton.style.display = "none";
}
}
// When the user clicks on the button, scroll to the top of the document
function topFunction() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
}
</script>