function scrollBanner() {
jQuery(document).on('scroll', function(){
var scrollPos = jQuery(this).scrollTop();
jQuery('.home_banner').css({
'top' : (scrollPos/4)+'px',
});
});
}
scrollBanner();
// With out function
jQuery(document).ready(function(){
jQuery(window).on('scroll', function(){
var scrollTop = jQuery(window).scrollTop();
jQuery('.home_banner').css({'top': (scrollTop/4) +'px'});
});
});
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter