Update index.html, main.css, main.js

This commit is contained in:
XenGi 2022-02-08 21:07:24 +00:00
commit b9d7c425a5
3 changed files with 40 additions and 0 deletions

View file

@ -10,6 +10,11 @@
<link rel="stylesheet" href="css/main.css" />
</head>
<body>
<button class="button is-primary is-medium is-responsive" onclick="gototop()" id="gototop_button" title="Go to top">
<span class="icon is-medium">
<i class="fas fa-solid fa-angles-up"></i>
</span>
</button>
<nav class="navbar">
<div class="container">

View file

@ -0,0 +1,19 @@
#topbutton {
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 */
}
#topbutton:hover {
background-color: #555; /* Add a dark-grey background on hover */
}

16
main.js
View file

@ -0,0 +1,16 @@
// Show button on scroll
window.onscroll = function() {toggle_gototop_button()};
function toggle_gototop_button() {
gototop_button = document.getElementById("gototop_button");
if (document.body.scrollTop > 23 || document.documentElement.scrollTop > 23) {
gototop_button.style.display = "block";
} else {
gototop_button.style.display = "none";
}
}
function gototop() {
document.body.scrollTop = 0; // For Safari
document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
}