Search code examples
javascriptjqueryhtmlcssmaterialize

Do you need any special image for getting Parallax effect in Materialize.css?


I am using Materialize CSS.

My code :

<div class="parallax-container">
    <div class="parallax">
        <img src="../../public/assets/img/mount.jpg" />        
    </div>    
</div>

<div class="parallax-container">
    <div class="parallax">
         <img src="http://www.mrwallpaper.com/wallpapers/landscape-georgia.jpg">
     </div>   
</div>

Only the second image seems to get a parallax effect while scrolling whereas the first one seems to move with the same speed. mount.jpg is just a random image in my computer.

And.. of course I did initialize parallax in javascript.

$('.parallax').parallax();


Solution

  • I update your Fiddle here https://jsfiddle.net/nmdd876c/2/

    Everything's fine. I only clean-up your html & correct your external resources.

    <!-- Compiled and minified CSS -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.1/css/materialize.min.css">
    
    <!-- Compiled and minified JavaScript -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.1/js/materialize.min.js"></script>
    

    I even try different images & it's working fine.