vladislavkopilov

fixed header

Dec 29th, 2014
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script src="js/jquery-2.1.1.min.js"></script>
  2.  
  3. <div class="headfix">
  4. </div>
  5.  
  6. <style>
  7. .headfix{
  8.     display: none;
  9.     position: fixed;;
  10.     width: 100%;
  11.     top: 0px;
  12.     z-index: 30;
  13. }
  14. </style>
  15.  
  16. <script>
  17.  $(document).ready(function(){
  18.         $(window).scroll(function(){
  19.                 if( $(window).scrollTop() > 200 ) { /*200 - расстояние в пикселях от верхушки body*/
  20.                         $('.headfix').css({display: 'block'});
  21.                        
  22.                 } else {
  23.                         $('.headfix').css({display: 'none'});
  24.                 }
  25.         });
  26.     });
  27. </script>
Advertisement
Add Comment
Please, Sign In to add comment