例:メニューを水平方向(ヘッダー上)に配置し、ページを下にスクロールすると(上から約> 100px)、メニュー(水平方向)がブラウザーの左側(垂直方向)に移動し、そこで固定されます...
何か助けはありますか?
例:メニューを水平方向(ヘッダー上)に配置し、ページを下にスクロールすると(上から約> 100px)、メニュー(水平方向)がブラウザーの左側(垂直方向)に移動し、そこで固定されます...
何か助けはありますか?
これを試して:
これがjsFiddleとsourceの動作です。
$(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'); }
});