일정위치에서 상단으로 스크롤되는 스크립트

2016. 3. 15. 17:37 Web/Mobile

<p class="goTop"><a href="#">맨위로</a></p> 

 




.goTop {

  width: 42px;

  height: 42px;

  background: #5acbd7;

  border-radius: 50%;

  opacity: 0.7;

  z-index: 100;

  a {

    display: block;

    padding-top: 22px;

    padding-top: 2.2rem;

    color: #fff;

    text-align: center;

    font-size: 11px;

    background: url("../../images/mo/ico_gnb.png") no-repeat 0 0;

    background-size: 320px 400px;

    background-position: -32px -137px;

  }

}

 



<script>

$(".goTop").hide();

$('.goTop').click(function(){

$('html, body').animate({scrollTop:0}, 300);

});

$(window).scroll(function(){

var conH = $("footer").height() + 90;

temp = $(window).scrollTop();

if( temp = $(window).scrollTop() ) {

$(".goTop").fadeIn();

} else {

$(".goTop").fadeOut();

}

$(".goTop").css({"position" : "fixed" , "bottom" : conH + "px" , "right" : "5px"});

});

</script>


'Web > Mobile' 카테고리의 다른 글

일정위치에서 부드럽게 스크롤되는 toTop 플러그인  (0) 2016.03.15
[JQuery UI]버튼 UI  (0) 2013.01.25
[JQuery UI]폼 UI  (0) 2013.01.25
[JQuery UI]콘텐츠 영역 접이식 패널  (0) 2013.01.25
간편한 header, footer  (0) 2013.01.25
Copyright © HuckleberryM All Rights Reserved | JB All In One Designed by CMSFactory.NET