pixelcog / parallax.js

Simple parallax scrolling effect inspired by Spotify.com implemented as a jQuery plugin
MIT License
3.53k stars 838 forks source link

Text Scrolling #245

Closed 914digital closed 6 years ago

914digital commented 6 years ago

Is there a way to make the text in front of an image have the same parallax effect? Great plugin!!

wstoettinger commented 6 years ago

Hey @danhanee ,

sure! you just have to put the text inside the .parallax-slider div together with the image.

check this example:

<div class="parallax-window">
  <div class="parallax-slider">
    <img src="/path/to/image.jpg" srcset="/path/to/image-400px.jpg 400w, /path/to/image-800px.jpg 800w, /path/to/image-1200px.jpg 1200w" sizes="100vw">
   <p>This text will move with the image</p>
  </div>
</div>
$('.parallax-window').parallax({
    naturalWidth: 600,
    naturalHeight: 400
  });
wstoettinger commented 6 years ago

since this is more a question than an issue, i will close it now. hope you are okay with it!