아래 내용으로 lib(테마/lib)에 button_top.php파일(첨부파일)을 만들어 넣으세요.
[code]
<button type="button" id="button_top">
<i class="fa fa-arrows-v" aria-hidden="true"></i><span class="sound_only">상단으로</span>
</button>
<script>
jQuery(function($) {
var $elem = $("html, body");
var where = 0;
$("#button_top").on("click", function() {
var windowHeight = $(document).height() - $(window).height();
var winhalf = windowHeight * 0.5; // Calculate the new winhalf value
if ($elem.scrollTop() < winhalf) {
$elem.animate({ scrollTop: $elem.prop("scrollHeight") }, 400);
where = 1;
} else {
$elem.animate({ scrollTop: 0 }, 400);
where = 0;
}
});
});
$(document).ready(function() {
$(window).scroll(function() {
var windowHeight = $(document).height() - $(window).height();
var winhalf = windowHeight * 0.5; // Calculate the new winhalf value
var scrollPos = $(document).scrollTop();
var scrollPercent = (scrollPos / windowHeight) * 100;
var $buttonTop = $('#button_top'); // Selector variable
if (scrollPos > winhalf) {
$buttonTop.css({
"border-color": "red",
"color": "red"
}).html("<i class='fa fa-arrow-up' aria-hidden='true'></i>");
} else {
$buttonTop.css({
"border-color": "blue",
"color": "blue"
}).html("<i class='fa fa-arrow-down' aria-hidden='true'></i>");
}
// 퍼센트 출력 시작.
if ($('#scroll_percentage').length === 0)
{
$('<p id="scroll_percentage"></p>').appendTo($buttonTop);
}
$('#scroll_percentage').text(Math.round(scrollPercent));
// 퍼센트 출력 끝.
// 다크모드 시작.
var xhr = new XMLHttpRequest();
xhr.open('HEAD', '<?php echo G5_THEME_CSS_URL?>/default_dark.css', false);
xhr.send();
if (xhr.status == "200") {
if (scrollPos > 100 && scrollPos < 200) {
$('#button_top').css("display", "none");
$('.fix_ch').css("display", "block");
} else {
$('.fix_ch').css("display", "none");
$('#button_top').css("display", "block");
}
} else {
// alert(xhr.status + "파일이 없습니다.");
}
// 다크모드 끝.
// 메뉴 상단고정 시작.
if (!g5_is_mobile) {
$('#gnb').css({
"display": "block",
"z-index": "10000"
});
if (scrollPos > 186) {
$('#gnb').css({
"position": "fixed",
"top": "0",
"width": "100%"
});
} else {
$('#gnb').css({
"position": "relative"
});
}
}
// 메뉴 상단고정 끝.
});
});
</script>
<style>
#top_btn, .fix_ch {
display:none
}
#button_top {
position: fixed;
bottom: 20px;
right: 3px;
width: 43px;
height: 43px;
line-height: 40px;
border-radius: 50%;
border: 1px solid #33333310;
color: #333;
text-align: center;
font-size: 15px;
z-index: 220;
background: rgba(255, 255, 255, 0.5);
}
#button_top:hover {
border-color: #3059c750;
background: #3059c750;
color: #333;
}
#scroll_percentage {
font-size: 12px;
margin-top: -27px;
font-weight: bold;
z-index: 999;
}
</style>
[/code]
tail.sub.php 상단 ?>바로 위에 아래내용 추가
[code]$config['cf_theme'] ? include_once(G5_THEME_PATH.'/lib/button_top.php') : include_once(G5_PATH.'/lib/button_top.php');[/code]
댓글 6개
게시글 목록
| 번호 | 제목 |
|---|---|
| 17657 | |
| 17655 | |
| 17654 | |
| 17653 |
JavaScript
ThreeJS - 3D Bar and Progress Bar
1
|
| 17652 |
node.js
RAM점유크기에 의한 노드서버관리
|
| 17651 |
JavaScript
Javascript Undo, Redo 기능 구현하기
|
| 17650 | |
| 17642 |
node.js
nodejs서버가 사용중인 메모리에 대한 로그
|
| 17633 |
node.js
node.js에서 스케쥴링작성
8
|
| 17632 | |
| 17631 |
MySQL
InnoDB와 MyISAM의 우단점
|
| 17630 | |
| 17628 |
JavaScript
자바스크립트 기반으로 HTML Canvas에 이미지를 불러들여 테두리색입히기
|
| 17624 | |
| 17623 | |
| 17620 |
node.js
tcp소켓과 websocket 의 비교
2
|
| 17618 |
JavaScript
JavaScript로 이미지의 부분 영역을 따내기
|
| 17617 | |
| 17614 | |
| 17612 | |
| 17611 | |
| 17610 | |
| 17609 | |
| 17608 |
node.js
Node.js로 지속적인 핑 결과를 파일로 저장
|
| 17607 |
정규표현식
특수문자 제거, 우리글짜가 있는지 체크
|
| 17604 |
node.js
Node.js에서 PDF 파일의 페이지 수를 얻기
|
| 17603 | |
| 17602 |
node.js
Node.js로 워터마킹 기능을 구현하는 방법
|
| 17600 | |
| 17594 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기