javascript - I am having trouble with a Js code for a parallax effect -


i trying make parallax effect landing page image stays still body paragraph below comes , on image. have works image still moves , white space shows on top.

js:

function scrollfooter(scrolly, heightfooter) { console.log(scrolly); console.log(heightfooter);  if(scrolly >= heightfooter) {     $('footer').css({         'bottom' : '0px'     }); } else {     $('footer').css({         'bottom' : '-' + heightfooter + 'px'     }); } }  $(window).load(function(){ var windowheight        = $(window).height(),     footerheight        = $('footer').height(),     heightdocument      = (windowheight) + ($('').height()) + ($('footer').height()) - 20;   $('#scroll-animate, #scroll-animate-main').css({     'height' :  heightdocument + 'px' }); 

thanks again help!

$('header').css({     'height' : windowheight + 'px',     'line-height' : windowheight + 'px' });   scrollfooter(window.scrolly, footerheight);  window.onscroll = function(){     var scroll = window.scrolly;      $('#scroll-animate-main').css({         'top' : '-' + scroll + 'px'     });      $('header').css({         'background-position-y' : 50 - (scroll * 400 / heightdocument) + '%'     });      scrollfooter(scroll, footerheight); } }); 

you don't need use jquery parallax effect on html page. simple css can satsify need.

.parallaxeffect { background-color: //color wanted or use background-image: url(your link); height: //your height background-repeat: no-repeat; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; position: fixed; //fixed pic not change relative otherwise effect lost width: 100%;}  .parallaxtitle { //remove if don't need put title inside image font-size: 80px; color: #eee; margin-top: 10%; text-align: center;}       .yourcontent { max-width: 100%; position: relative; top: 400px; padding: 0px; font-size: 20px; background-color: #fff;} 

your need apply below website sort, can advance modification in order fulfill requirement.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -