Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
leafo.net/sticky-kit
bigspotteddog.github.io/ScrollToFixed
If you want to write it yourself, then listen for the scroll event and read the scrollTop coordinate (in the case of a vertical scroll). In this case, the coordinate must be compared with the absolute position of the block you need along the desired axis.
$(function(){
$(window).scroll(function(){
if ( $(this).scrollTop() > height ){
$('.menu').addClass("fixed");
} else {
$ ('.menu.fixed').removeClass("fixed");
}
});
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question