하/중/상 스크롤

<style>
.go-up {position: fixed;right:25px;bottom:158px;border-radius: 5px;color: rgba(80,80,80,0.3);text-align: center;width: 25px;height: 25px;font-size: 16px;background-color:rgba(80,80,80,0.0);z-index: 999;display: none;}
.go-up:hover{color:rgba(0,0,255,0.6);}
.go-center {position: fixed;right:25px;bottom:135px;border-radius: 5px;color: rgba(80,80,80,0.3);text-align: center;width: 25px;height: 25px;font-size: 10px;background-color:rgba(80,80,80,0.0);z-index: 999;display: none;}
.go-center:hover{color:rgba(0,0,255,0.6);}
.go-down {position: fixed;right:25px;bottom:120px;border-radius: 5px;color: rgba(80,80,80,0.3);text-align: center;width: 25px;height: 25px;font-size: 16px;background-color:rgba(80,80,80,0.0);z-index: 999;display: none;}
.go-down:hover{color:rgba(0,0,255,0.6);}
</style>
<a href="#" class="go-up"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
<a href="#" class="go-center"><i class="fa fa-circle" aria-hidden="true"></i></a>
<a href="#" class="go-down"><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$( window ).scroll( function() {
if ($(this).scrollTop() > 100 ) {
$('.go-up').fadeIn();
$('.go-center').fadeIn();
$('.go-down').fadeIn();
} else {
$('.go-up').fadeOut();
$('.go-center').fadeOut();
$('.go-down').fadeOut();
}
});
});
$(function() {
$(".go-up").on("click", function(e) {
e.preventDefault();
$("html, body").animate({scrollTop:0}, '500');
return false;
});
$(".go-center").on("click", function(e) {
e.preventDefault();
var middle_pos = $("body").offset().top - ( $(window).height() - $("body").outerHeight(true) ) / 2;
$("html, body").animate({scrollTop:middle_pos}, '500');
return false;
});
$(".go-down").on("click", function(e) {
e.preventDefault();
var scrollBottom = $("html,body").scrollTop + $("html,body").height();
$("html, body").animate({scrollTop:$(document).height()}, '500');
return false;
});
});
</script>
댓글 12개
"font-awesome.min.css"가 없으면 추가하세요.
go-center를 클릭하면 중간(중단)으로 가지 않고 go-up처럼 그냥 맨위로 올라가버리는군요~
var middle_pos = $("body").offset().top - ( $(window).height() - $("body").outerHeight(true) ) / 2;
위의 내용을 수정하여야 할 것 같은데...실력이 없어서...ㅜ
잘 사용하겠습니다.
어느(익스,엣지)것에서 안되나요?
2. 그리고 화면을 확대하면 화살표가 왼쪽으로 이동하여 내용이 있는 곳으로 들어갑니다.
확대를 하거나 축소를 해도 그 자리에 있도록 하려면...
.go-up {position:fixed;right:25px;bottom:158px;를
.go-up {position:fixed;right:50%;margin-right:-570px;bottom:158px; 이런 식으로 사용해야 할 것 같습니다.
확인하겠습니다.
제컴이 크롬이 안깔려 있어서..
위치 조정은 취향에 맞추어 사용하세요.
게시판 목록
그누보드5 팁자료실
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 공지 | 3년 전 | 4402 | ||
| 2604 | 8개월 전 | 673 | ||
| 2603 | 8개월 전 | 733 | ||
| 2602 | 8개월 전 | 648 | ||
| 2601 |
|
8개월 전 | 670 | |
| 2600 |
|
8개월 전 | 579 | |
| 2599 | 8개월 전 | 808 | ||
| 2598 | 8개월 전 | 602 | ||
| 2597 |
다케미카코
|
8개월 전 | 755 | |
| 2596 | 8개월 전 | 854 | ||
| 2595 |
|
8개월 전 | 446 | |
| 2594 | 9개월 전 | 608 | ||
| 2593 |
만두먹고또먹고
|
9개월 전 | 935 | |
| 2592 | 9개월 전 | 609 | ||
| 2591 | 9개월 전 | 620 | ||
| 2590 | 9개월 전 | 688 | ||
| 2589 |
|
9개월 전 | 757 | |
| 2588 | 9개월 전 | 476 | ||
| 2587 | 9개월 전 | 796 | ||
| 2586 | 9개월 전 | 643 | ||
| 2585 | 9개월 전 | 509 | ||
| 2584 | 9개월 전 | 576 | ||
| 2583 | 9개월 전 | 498 | ||
| 2582 | 9개월 전 | 640 | ||
| 2581 | 9개월 전 | 598 | ||
| 2580 |
만두먹고또먹고
|
9개월 전 | 517 | |
| 2579 |
|
9개월 전 | 664 | |
| 2578 | 9개월 전 | 646 | ||
| 2577 | 9개월 전 | 625 | ||
| 2576 | 9개월 전 | 561 | ||
| 2575 |
이슈DEV
|
10개월 전 | 993 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기