상단 메뉴 고정 부드럽게 스크롤하기 (점프 안함)

구글링해서 찾았습니다

kcmschool.com/15 에서 찾았습니다
pc mobile에서 스크롤 시 점프없이 상단 메뉴 고정됩니다

---> /js/jquery-1.8.3.min.js 사용

<script type="text/javascript">
    $(document).ready(function(){
        var topBar = $("#topBar").offset();
        $(window).scroll(function(){
            var docScrollY = $(document).scrollTop()
            var barThis = $("#topBar")
            var fixNext = $("#fixNextTag")
            if( docScrollY > topBar.top ) {
                barThis.addClass("top_bar_fix");
                fixNext.addClass("pd_top");
            }else{
                barThis.removeClass("top_bar_fix");
                fixNext.removeClass("pd_top");
            }
        });
    })
</script>

<style type="text/css">
body {margin:0;padding:0;}
.wrap{font-size:70px}
.wrap div{width:100%; text-align:center; font-size:70px; color:#fff;}
.top_bar_fix{position:fixed; top:0; left:0;}
.pd_top{padding-top:150px;}
.wrap .top_bn_zone{height:300px; background:#777; line-height:30px;}
.wrap .top_fix_zone{clear:both; height:150px; background:#d63232; line-height:30px;}
.wrap .top_con_zone{clear:both; background:#ededed; color:#888; text-align:center; font-size:70px;}
</style>

</head>
<body>
        
<div class="wrap">

 <div class="top_bn_zone">
        <br><br>상단 title 영역
 </div>

 <div class="top_fix_zone" id="topBar">
        <br><br>상단 MENU 고정 영역
 </div>

 <div class="top_con_zone" id="fixNextTag">
        하단 contents 영역
 </div>

</div>

첨부파일

test.php (2.2 KB) 151회 2019-03-07 13:42
|

댓글 8개

감사합니다
좋은 정보 감사합니다.
정보 감사합니다.
경계선에서 흰색바탕이 보이는 부분 안보이게는
댓글을 작성하시려면 로그인이 필요합니다.

그누보드5 팁자료실

+
제목 글쓴이 날짜 조회
6년 전 조회 6,056
6년 전 조회 4,030
6년 전 조회 9,049
6년 전 조회 4,875
6년 전 조회 4,755
6년 전 조회 3,686
6년 전 조회 3,587
6년 전 조회 4,169
6년 전 조회 6,047
6년 전 조회 5,464
6년 전 조회 4,240
6년 전 조회 4,678
6년 전 조회 3,805
6년 전 조회 3,712
6년 전 조회 6,800
6년 전 조회 4,312
6년 전 조회 5,790
6년 전 조회 5,146
6년 전 조회 6,433
6년 전 조회 5,543
6년 전 조회 5,030
6년 전 조회 4,181
6년 전 조회 6,069
6년 전 조회 1.4만
6년 전 조회 4,142
6년 전 조회 5,046
6년 전 조회 4,855
6년 전 조회 4,249
6년 전 조회 3,485
6년 전 조회 4,246