맨위로 가기 버튼 > 그누보드5 팁자료실

그누보드5 팁자료실

맨위로 가기 버튼 정보

맨위로 가기 버튼

본문

팁이랄건 없구요.

고수님들은 패스~~~

그냥 필요에 의해서 구글링 해서 맞게 수정해봤습니다.

일단, 저희 사이트에선 잘 구동해서 맨날 얻어만 가는 보답을 좀 해 봅니다.

 

<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>

 

추천
1

댓글 4개

전체 2,426 |RSS
그누보드5 팁자료실 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT