Blogroll

Wednesday, January 11, 2012

Make auto scroll when page scroll

Link demo 
Technique: auto scroll follow window scroll top and set margin-top for scroll element.

 
 
Scroller
And this is css code
   #wrapper{
    width:1000px;
    height:1500px;
    background:#f7f7f7;
    margin:auto;
   }
   #scroll{
    color:#fff;
    height:40px;
    width:80px;
    background:#333;
    position:absolute;
    top:200px;
    left:10px;
    
   }
Finally javascript code
   $(document).ready(function(){
   $(window).scroll(function(){
    
    var k =$(this).scrollTop();
    $('#scroll').stop(true).animate({
    marginTop: k }, 500, function() {
    // Animation complete.
  });
   })
   });
Olá! Se você ainda não assinou, assine nosso RSS feed e receba nossas atualizações por email, ou siga nos no Twitter.
Nome: Email:

0 comments:

Post a Comment