側邊欄(滾動時要固定的元素)position:absolute, 其父元素position:relativecss
使用如下js代碼:spa
<script>ip
sd = $('.sd').offset().top;it
$(window).scroll(function(){io
if(wtop > sd) {function
$('.sd').css({'top':wtop-sd});scroll
}else {top
$('.sd').css({'top':0});position
}script
});
</script>