jquery - Parallax background doesn't work in firefox and safari -
i have problem parallax background in firefox , safari. when test in chrome, opera , ie works.
in firefox/safari see empty spacing on top , bottom.
in these browsers, background moves @ different speed.
this code:
<section class="main"> <div class="top-slider-wrapper w-100 fl relative"> <div class="top-slider w-100 fl"> <?php foreach ($tbanery $tb): ?> <div class="slide-item w-100"> <div class="parallax w-100 tc tl-md pv6 pv7-sm fl" style="background-image: url('img/<?php echo $tb->zdjecie; ?>');"> <div class="container cf"> <h2 class="fc-light fw4 ttu pl2-md mt0 mb2"><?php print $tb->nazwa; ?></h2> <p class="fc-light ttu pl2-md"><?php print $tb->opis; ?></p> <div class="buttons"> <a href="#" class="btn btn-grey ma2">kontakt</a> <a href="#" class="btn btn-red ma2">zamów</a> </div> </div> </div> </div> <?php endforeach; ?> </div> </div>
var paralaxbg = function() { $('.parallax').each(function() { $(this).css('background-attachment', 'fixed'); if ($(this).isonscreen()) { var difference = $(window).scrolltop() - $(this).offset().top; var half = (difference / 3) + 'px'; $(this).css('background-position', '0% calc(50% - ' + half + ')'); } }); }; .parallax { background-position: center; background-repeat: no-repeat; background-size: cover; }
Comments
Post a Comment