prvni várka
This commit is contained in:
11
Go-To-Up/index.html
Normal file
11
Go-To-Up/index.html
Normal file
@ -0,0 +1,11 @@
|
||||
<head>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css"
|
||||
/>
|
||||
</head>
|
||||
<body>
|
||||
<button onclick="scrollToTop()" id="scrollToTopBtn" title="Go to top">
|
||||
<i class="fas fa-arrow-up"></i>
|
||||
</button>
|
||||
</body>
|
19
Go-To-Up/script.js
Normal file
19
Go-To-Up/script.js
Normal file
@ -0,0 +1,19 @@
|
||||
// Tlačítko go to top
|
||||
// Zobrazení tlačítka od rolovaní části stránky (víc logické než až na konci)
|
||||
window.onscroll = function () {
|
||||
scrollFunction();
|
||||
};
|
||||
|
||||
function scrollFunction() {
|
||||
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
|
||||
document.getElementById("scrollToTopBtn").style.display = "block";
|
||||
} else {
|
||||
document.getElementById("scrollToTopBtn").style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
// Posunout nahoru, když uživatel klikne na tlačítko
|
||||
function scrollToTop() {
|
||||
document.body.scrollTop = 0; // Pro Safari
|
||||
document.documentElement.scrollTop = 0; // Pro ostatní prohlížeče
|
||||
}
|
14
Go-To-Up/style.css
Normal file
14
Go-To-Up/style.css
Normal file
@ -0,0 +1,14 @@
|
||||
/* Go to go */
|
||||
#scrollToTopBtn {
|
||||
display: none;
|
||||
position: fixed;
|
||||
bottom: 20px;
|
||||
right: 20px;
|
||||
/*butoon přes obsah*/
|
||||
z-index: 99;
|
||||
outline: none;
|
||||
cursor: pointer;
|
||||
padding: 15px;
|
||||
border-radius: 50%;
|
||||
background-color: transparent;
|
||||
}
|
Reference in New Issue
Block a user