jQuery спасает день ... снова!
CSS:
#wrapper {
position: absolute;
width: 200px;
}
#fancyDiv {
position: absolute;
top: 0;
}
#fancyDivt.fixed {
position: fixed;
top: 0;
}
HTML:
* +1007 *
JQuery:
$(document).ready(function() {
$(function () {
var top = $('#fancyDiv').offset().top - parseFloat($('#fancyDiv').css('margin-top').replace(/auto/, 0));
$(window).scroll(function (event) {
// what the y position of the scroll is
var y = $(this).scrollTop();
// whether that's below the div
if (y >= top) {
// if so, ad the fixed class
$('#fancyDiv').addClass('fixed');
} else {
// otherwise remove it
$('#fancyDiv').removeClass('fixed');
}
});
}
});