맨위로 가기 버튼
팁이랄건 없구요.
고수님들은 패스~~~
그냥 필요에 의해서 구글링 해서 맞게 수정해봤습니다.
일단, 저희 사이트에선 잘 구동해서 맨날 얻어만 가는 보답을 좀 해 봅니다.
<style>
#myBtn {
display: none;
position: fixed;
bottom: 20px;
right: 30px;
z-index: 99;
font-size: 18px;
border: none;
outline: none;
background-color: red;
color: white;
cursor: pointer;
padding: 15px;
border-radius: 4px;
}
#myBtn:hover {
background-color: #555;
}
</style>
<button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
<script>
// Get the button
let 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>
댓글 6개
감사합니다 덕북에 해결했어요~
감사합니다. 유용하게 잘 쓰겠습니다.
게시판 목록
그누보드5 팁자료실
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 공지 | 3년 전 | 4427 | ||
| 2394 | 1년 전 | 5051 | ||
| 2393 |
|
1년 전 | 1700 | |
| 2392 |
|
1년 전 | 1358 | |
| 2391 |
|
1년 전 | 1141 | |
| 2390 |
|
1년 전 | 1197 | |
| 2389 | 1년 전 | 1781 | ||
| 2388 | 1년 전 | 1328 | ||
| 2387 | 1년 전 | 1310 | ||
| 2386 |
투명한열정
|
1년 전 | 3074 | |
| 2385 |
|
1년 전 | 2348 | |
| 2384 | 1년 전 | 1670 | ||
| 2383 | 1년 전 | 1807 | ||
| 2382 | 1년 전 | 1456 | ||
| 2381 |
|
1년 전 | 1874 | |
| 2380 | 1년 전 | 1044 | ||
| 2379 | 1년 전 | 1385 | ||
| 2378 | 1년 전 | 919 | ||
| 2377 | 1년 전 | 2999 | ||
| 2376 | 1년 전 | 1565 | ||
| 2375 | 1년 전 | 1737 | ||
| 2374 |
네이비스택
|
1년 전 | 1118 | |
| 2373 | 1년 전 | 1550 | ||
| 2372 | 1년 전 | 1472 | ||
| 2371 |
goodman148
|
1년 전 | 2112 | |
| 2370 | 1년 전 | 1521 | ||
| 2369 |
|
1년 전 | 1033 | |
| 2368 | 1년 전 | 1836 | ||
| 2367 | 1년 전 | 1357 | ||
| 2366 |
|
1년 전 | 1214 | |
| 2365 | 1년 전 | 2146 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기