两侧跟随广告
思路:当鼠标滚动的时候左右两边广告跟着滚动
html
1 <div class="left"><img src="images/1.gif" alt=""/></div> 2 <div class="right"><img src="images/2.gif" alt=""/></div>
css
1 .left,.right{ 2 position: absolute; 3 top:80px; 4 } 5 .left{ 6 left: 0; 7 } 8 .right{ 9 right: 0; 10 }
jquery
1 $(function(){ 2 $(window).scroll(function () { 3 var top = $(document).scrollTop(); 4 $(".left").stop().animate({"top" : top + 50},600); 5 $(".right").stop().animate({"top" : top + 50},600); 6 7 // $(".left,.right").stop().animate({"top" : top + 50},600); 8 }); 9 });