這是相當困難,爲您提供一個完整的解釋,但我把這個在一起,讓你開始:
http://jsfiddle.net/Ms7gw/
HTML
<div id="container">
<div class="box" id="right"></div>
<div class="box" id="center"></div>
<div class="box" id="left"></div>
</div>
CSS
#container {height: 1000px; width: 1000px; background-color: #000;}
.box {width: 100px; height: 100px; position: absolute; left: 50%; top: 50%; margin-left: -50px; margin-top: -50px; background-color: #ff0000;}
#right {background-color: #aa0000;}
#left {background-color: #aa0000;}
JS
var lastScrollTop = 0;
var leftBox = $('#left').position();
var rightBox = $('#right').position();
$(window).scroll(function(event){
var st = $(this).scrollTop();
$('#right').css({left: rightBox.left + st});
$('#left').css({left: leftBox.left - st});
lastScrollTop = st;
});
謝謝。這是我一直在尋找的想法。現在,我可以根據我想到的設計和效果對其進行定製。 – prat1kk
很高興我能幫到你。如果它被認爲是解決您的問題,請接受答案並在左邊選中標記:) –