JS Kodu:
var stickEl = $('.sticky'),
stickyElTop = stickEl.offset().top;
var sticky = function(){
var scrollTop = $(window).scrollTop();
if (stickyElTop < scrollTop) {
stickEl.addClass('is-fixed');
} else {
stickEl.removeClass('is-fixed');
}
};
$(window).scroll(function() {
sticky();
});
CSS Kodu:
.reklam {
position: absolute;
top: 20em;
right:0;
width: 258px;
}
.is-fixed {
position: fixed;
top: 0px;
right:0;
width: 258px;
}
HTML Kodu:
test