하/중/상 스크롤

<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 팁자료실
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 2695 | 1개월 전 | 171 | ||
| 2694 | 1개월 전 | 134 | ||
| 2693 | 1개월 전 | 143 | ||
| 2692 | 1개월 전 | 158 | ||
| 2691 | 1개월 전 | 312 | ||
| 2690 | 1개월 전 | 217 | ||
| 2689 |
|
1개월 전 | 424 | |
| 2688 | 1개월 전 | 275 | ||
| 2687 |
선택과집중
|
1개월 전 | 313 | |
| 2686 | 1개월 전 | 275 | ||
| 2685 | 1개월 전 | 330 | ||
| 2684 | 2개월 전 | 462 | ||
| 2683 | 2개월 전 | 261 | ||
| 2682 | 2개월 전 | 287 | ||
| 2681 |
선택과집중
|
2개월 전 | 263 | |
| 2680 | 2개월 전 | 313 | ||
| 2679 |
|
2개월 전 | 417 | |
| 2678 |
|
2개월 전 | 487 | |
| 2677 | 2개월 전 | 312 | ||
| 2676 | 2개월 전 | 287 | ||
| 2675 |
선택과집중
|
2개월 전 | 464 | |
| 2674 |
|
2개월 전 | 309 | |
| 2673 | 2개월 전 | 322 | ||
| 2672 | 2개월 전 | 272 | ||
| 2671 | 2개월 전 | 244 | ||
| 2670 | 2개월 전 | 356 | ||
| 2669 | 2개월 전 | 274 | ||
| 2668 |
선택과집중
|
2개월 전 | 470 | |
| 2667 |
선택과집중
|
2개월 전 | 455 | |
| 2666 |
선택과집중
|
3개월 전 | 388 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기