လုပ်နည်း - အပေါ်မှ ခလုတ်ကို ပြန်ရွှေ့ပါ။
CSS ဖြင့် "အပေါ်သို့ပြန်ရွှေ့ရန်" ခလုတ်ကို ဖန်တီးနည်းကို လေ့လာပါ။
အပေါ်ဆုံးခလုတ်ကို Scroll ဖန်တီးနည်း
အဆင့် 1) HTML ကိုထည့်ပါ
နှိပ်လိုက်သောအခါ အသုံးပြုသူကို စာမျက်နှာ၏ထိပ်သို့ ခေါ်ဆောင်သွားမည့် ခလုတ်တစ်ခုကို ဖန်တီးပါ-
ဥပမာ
<button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
အဆင့် 2) CSS ကိုထည့်ပါ
ခလုတ်ပုံစံ-
ဥပမာ
#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: red; /* 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 */
font-size:
18px; /* Increase font size */
}
#myBtn:hover {
background-color: #555; /* Add a dark-grey background on hover */
}
အဆင့် 3) JavaScript ကိုထည့်ပါ။
ဥပမာ
//Get the button:
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; // For Safari
document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
}