개인공간

[제이쿼리] fixed였던 오브젝트 스크롤 하단 특정위치에 고정시키기 본문

IT정보/jQuery_javaScript

[제이쿼리] fixed였던 오브젝트 스크롤 하단 특정위치에 고정시키기

천재소년s 2023. 7. 12. 13:56
반응형
fix하단 적용 테스트

CSS

.fix_bottom_230712 {position:fixed;left:0;bottom:0;z-index:10;width:400px;height:70px;backgorund:red;}

HTML

fix하단 적용 테스트

JS

$(window).scroll(function(){
    var scrollTop = $(this).scrollTop();
    var innerHeight = $(this).innerHeight();
    var scrollHeight = $('body').prop('scrollHeight');
    var notiTop = $('#recent-post').offset().top; //멈출곳

    /*if (scrollTop + innerHeight >= scrollHeight - $('#recent-post').outerHeight(true)) {*/
    if (scrollTop + innerHeight >= notiTop){
    	$('.fix_bottom_230712').addClass('endhide');
    }else{
    	$('.fix_bottom_230712').removeClass('endhide');
    }
});
반응형