loading

티스토리 프로그래스바, 스크롤바, 진행바 html 적용하는 방법

블로그|2020. 10. 4. 08:51


이번 포스팅은 스크롤바, 프로그래스바, 진행바 등의 다양한 이름으로 부를 수 있는 것을 티스토리에 적용하는 법을 알려드리려고 합니다.

진행바는 위와 같이 본문을 내릴 때 본문의 상태를 표시해주는 것을 말합니다.

방법은 매우 간단하니 차근차근 따라와주세요.


먼저 스킨편집으로 들어가세요.

그 다음 html 편집으로 들어가세요.

먼저 CSS 탭으로 넘어가서 아래의 코드를 복사해서 맨 아래 부분에 추가해주세요.


복사할 css 코드

.header {

  position: fixed;

  top: 0;

  z-index: 1;

  width: 100%;

  background-color: #fff;

}

.progress-container {

  width: 100%;

  height: 3px;

  background: #f6f6f6;

}

.progress-bar {

  height: 3px;

  background: #dbbbbb;

  width: 0%;

}

 

.progress-container height 부분은 진행바의 겉테두리 두께입니다.

.progress-bar height 부분은 진행바의 두께입니다.

본인이 편하신대로 조정하시면 됩니다.


위 색상코드표를 참고하셔서 본인 취향대로의 진행바 색상을 선택해보세요.

다음은 html 로 들어가서 <body> 부분을 찾으세요.

<body> 일수도 있고 저처럼 <body id=xxx> 일수도 있습니다.

정 못찾으시겠으면 </body> 바로 위 부분에 붙여넣으세요.

body 바로 아래 부분에 아래의 코드를 붙여넣으시면 됩니다.

복사할 html 코드

<script>

// When the user scrolls the page, execute myFunction 

window.onscroll = function() {myFunction()};


function myFunction() {

  var winScroll = document.body.scrollTop || document.documentElement.scrollTop;

  var height = document.documentElement.scrollHeight - document.documentElement.clientHeight;

  var scrolled = (winScroll / height) * 100;

  document.getElementById("myBar").style.width = scrolled + "%";

}

</script>

 

이상 티스토리에 진행바를 적용하는 법이였습니다.


반응형

댓글()
반응형