-3

例:メニューを水平方向(ヘッダー上)に配置し、ページを下にスクロールすると(上から約> 100px)、メニュー(水平方向)がブラウザーの左側(垂直方向)に移動し、そこで固定されます...

何か助けはありますか?

4

1 に答える 1

4

これを試して:

これがjsFiddlesourceの動作です。

$(window).scroll(function() {

   var headerH = $('.header').outerHeight(true);
   //this will calculate header's full height, with borders, margins, paddings
   var scrollTopVal = $(this).scrollTop();
    if ( scrollTopVal > headerH ) {
        $('#subnav').css({'position':'fixed','top' :'0px'});
    } else {
        $('#subnav').css({'position':'static','top':'0px'});
    }

   var scrollLeftVal = $(this).scrollLeft();
   if ( scrollLeftVal > 1 ) { alert('i scrolled to the left'); }
});
于 2013-02-09T01:00:44.277 に答える