index.html
Код: Выделить всё
I am a header
I am some content
Код: Выделить всё
$(document).ready(function() {
var aboveHeight = $('#headerOne').outerHeight();
$('#contentContainer').scroll(function(){
if ($('#contentContainer').scrollTop() > aboveHeight){
$('#headerOne').addClass('fixed').css('top','0').next().css('padding-top','60px');
} else {
$('#headerOne').removeClass('fixed').next().css('padding-top','0');
}
});
});
Код: Выделить всё
$(document).ready(function() {
var aboveHeight = $('#headerOne').outerHeight();
$(window).scroll(function(){
if ($(window).scrollTop() > aboveHeight){
$('#headerOne').addClass('fixed').css('top','0').next().css('padding-top','60px');
} else {
$('#headerOne').removeClass('fixed').next().css('padding-top','0');
}
});
});
Может ли функция прокрутки обнаружить прокрутку div или это должна быть $(window). ?
Спасибо.
Подробнее здесь: https://stackoverflow.com/questions/135 ... v-position
Мобильная версия