Advertisement
Milotronik

Menu fixed

Apr 13th, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(function(){
  2. $(window).scroll(function(){ scroll_menu(); });
  3. $(window).load(function(){ scroll_menu(); });
  4. scroll_menu();
  5. });
  6.  
  7. function scroll_menu()
  8. {
  9. var offsetfilter = $("#header-wrapper").height() - 25;
  10. var scrollY = $(window).scrollTop();
  11. var menu = $('#top-container');
  12. if(scrollY > offsetfilter)
  13. {
  14. menu
  15. .css('position','fixed')
  16. .css('top', '-113px');
  17. }
  18. else
  19. {
  20. menu
  21. .css('position','absolute')
  22. .css('top', '0px');
  23. }
  24. }
  25.  
  26. //HTML
  27. <div id="top-container" style="position: absolute; top: 0px; display: block; opacity: 1;">
  28. <div id="header-wrapper">
  29. <div id="menu-wrapper">
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement