Scroll to top

How To Create a Scroll To Top Button in php?

 Create a Scroll To Top Button

<html>
<head>
<script>
// 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 >500|| document.documentElement.scrollTop >500) {
    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;
  document.documentElement.scrollTop = 0;
}
</script>
<style>
#myBtn {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 30px;
  z-index: 99;
  font-size: 18px;
  border: none;
  outline: none;
  background-color:#EAC159;
  color: white;
  cursor: pointer;
  padding: 15px;
  border-radius:50%;
  opacity: 0.5;
}
#myBtn:hover {
  background-color: #555;
}
.red{
color:red;
}
</style>
<head>
<body>
<button onclick=”topFunction()” id=”myBtn” title=”Go to top”>Top</button>



<h1 class=”red” >hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
<h1>hello man how are you</h1>
</body>
</html>

Leave a Reply

Your email address will not be published.