用于视差滚动的最小 Skrollr 设置,如您链接到的示例中的山脉:
HTML -<body>
标签内:
<div class="skrollr-body">
<!--
Put the slow image here. It will scroll only 500px for 1000 pixels of
browser scroll, so 'half speed'.
-->
<div id="splash" data-0="top: 0px" data-1000="top: -500px">
<img src="..." />
</div>
<!--
Put your normal image here, which will scroll with parallax over the above
image. This will need a margin to push it below your fixed #splash. Set
its margin-top to the height of #splash and set its position to absolute.
-->
<div>
<img src="..." />
</div>
</div><!--/.skroll-body-->
一些CSS #splash
:
#splash {
position: fixed;
}
和一些 JS 来实现它。假设您使用的是 jQuery,否则您需要 document.onload:
$(document).ready(function() {
skrollr.init()
});
把它放在你的<head>
或底部<body>
。
演示 - http://jsfiddle.net/sifriday/1ugaooj0/