스크롤 위치에 따라 숨김/보임

by hlee0126

HTML

<div>
    <div class="a">
        A
    </div>
    
</div>

CSS

body {
    height: 2000px;    
}
.a {
    height: 300px;
    width: 300px;
    background-color: green;
    position:fixed;
    bottom:0;
    display: none;
 
}

JavaScript

$(window).scroll(function() {

    if ($(this).scrollTop()<200)
     {
        $('.a').fadeOut();
     }
    else
     {
      $('.a').fadeIn();
     }
 });