See this fiddle:
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() >= $(window).height()+101) {
$('#hello').css({'position':'fixed','top':'0px'});
}
else{
$('#hello').css({'position':'relative'});
}
});
I have included $(window).height()
in if(condition) inorder to give same output when the browser window height changes.