Pages - পৃষ্ঠাসমূহ

Animated scroll to top of the page using jquery

Animated to top of the page using jquery is easy and simple. Sometimes long pages need to easily navigate so that user can comfort to read whole pages if they want. This post show the scolling top of the pages. Here is the simple code given.

If you want to animated float menu you can learn this tutorial creating float menu using jquery
Hide Example Show Example

Animated to top of the page

It is easily done using jquery and decorate using css. It is a simple task. Now see this how to create scolling button.
<html>
<head>
<title>Animated scroll to top of the page using jquery</title>
   <script type="text/javascript"  src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script>
  <link rel="stylesheet" type="text/css" href="style.css"/>
   <script type="text/javascript" language="javascript">
  
   $(document).ready(function(){
         
  $(window).scroll(function () {  
   
   if($(this).scrollTop() > 500){  
    $(".demo").fadeIn();
    $(".demo").animate({top:offset},{duration:500,queue:false});  
   }
   else{
    $(".demo").fadeOut();
   }
   
   $('.demo').click(function () {
    $('body,html').animate({
     scrollTop: 0
    }, 1000);
    return false;    
   });
  });  

   });
   </script>
 
</head>
<body>
  <div id="header">
 <h1>Scrolling top of the page</h1>
  </div>
  <div class="demo"> 
 
  </div>
  <div class="text">
 <h4>Float menu</h4>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 
 <h4>Float menu</h4>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>

 
 <h4>Float menu</h4>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
 Animated scroll to top of the page using jquery<br/>
  </div>
   
</body>
</html>



style.css

After creating the upper page now decorate with css
  
  body{
   width:700px;
   margin:0 auto;
   position:relative;
   background:#193D36;
  }
  #header{
   width:100%;
   height:150px;
  }
  #header h1{
   color:white;
  }
  .demo{
   position: fixed;
   bottom: 30px;
   margin-left: -100px;
   background: url("top.png") no-repeat;
   color:white; 
   padding:0px;  
   width:60px;
   height:70px; 
   cursor:pointer; 
   display:none;   
  }  
  .text{
   width:700px;
   padding:20px;
   background:#f6f6f6;
   color:gray;
   
   
  }
 

No comments:

Post a Comment