[英]depth effect using Javascript (jQuery)
Does anyone know (as in http://james.padolsey.com/ ) how the upper body layer is scrolling at a faster speed while the background is scrolled at a slower speed making it give an effect of depth?? 有没有人知道(如在http://james.padolsey.com/中 )上身层如何以更快的速度滚动,而背景以较慢的速度滚动,使其产生深度效果?
Can I implement multiple layers (more then 2) scrolling at different speeds using the similar concept?? 我可以使用类似的概念实现多个层(超过2个)以不同的速度滚动吗?
Below is the bit of code that does this. 下面是执行此操作的代码。 I did not write it, just looked at his source and got it.
我没有写它,只是看着他的来源并得到它。
var a = document.body,
e = document.documentElement;
$(window).unbind("scroll").scroll(function () {
a.style.backgroundPosition = "0px " + -(Math.max(e.scrollTop, a.scrollTop) / 8) + "px"
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.