Parallax scroll easy

    $('.parallax').each(function(){
        var $bgobj = $(this); // assigning the object
    
        $(window).scroll(function() {
	       
            var yPos = -($(window).scrollTop() / .9); 
             //alert(yPos);
            // Put together our final background position
            var coords = '50% '+ yPos + 'px';

            // Move the background
            $bgobj.css({ backgroundPosition: coords });
        }); 
    }); 

Don’t forget to

.parallax {
	background-color: transparent;
	position: relative;
	background-image: url('http://whatever.jpg');
	background-attachment: fixed;
}
Comments