Made simple parallax but not working ..
CSS top asset not set or not ...
How to set the top to work vertically .. pz
& lt; Div class = "bg" & gt; & Lt; Div class = "container" & gt; & Lt; H1 & gt; Parallax effect & lt; / H1> & Lt; P class = "lead" & gt; Goes here & lt; / P & gt; & Lt; / Div & gt; & Lt; / Div & gt; In
CSS
.bg {background: url ('http://sharafmedia.com/images/banner05 Jpg ') Repeat; Background-position: center; Background size: cover; Width: 100%; Height: 300px; Top: 0; Left: 0; Z-index: -1; Padding: 10px; }
jQuery
function parallax () {var scrolled = $ (window) .scrollTop (); $ ('Bg'). CSS ('top', - (scroll * 0.3) + 'px'); Console.log ($ ('.bg'). Css ('top', - (scroll * 0.3) + 'px'); } $ (Window) .scroll (function (e) {parallax ();});
Try adding parseInt to the tagged scroll .
function parallax () {var scroll = $ (window) .scrollTop (); $ ('Bg'). CSS ('top', parsect (scroll * 0.3 * -1) + 'px'); Console.log ($ ('bg'). CSS ('top', parsect (scroll * 0.3 * -1) + 'px'); }
No comments:
Post a Comment