Hello, it is possible to do capturing the scroll event and check if the scrollTop is larger than the size you want.
I would use the following code
$(function(){
var jElement = $('.element');
$(window).scroll(function(){
if ( $(this).scrollTop() > 300 ){
jElement.css({
'position':'fixed',
'top':'300px'
});
}else{
jElement.css({
'position':'relative',
'top':'auto'
});
}
});
});
Where we save the variable of our element with the jElement
, we check when the user scrolls on the page with $(window).scroll();
and check if the scroll is larger than 300 (you can switch to any value you want) with $(this).scrollTop();
see an example working here:
http://jsfiddle.net/Wagner/cwzVQ/embedded/result/
Exactly this page uses a plugin: http://bigspotteddog.github.io/ScrollToFixed/ - but this is not difficult to do. If you put your code you will get a more personalized answer.
– Sergio
Cool Sergio.. I’ll test it. Thank you!
– Maicon