jquery - Persistent Header for web page -
i have looked @ several jquery methods of making persistent header, don't understand how functions work.
the basis of idea being, have drop down menu somewhere on page , when top of screen gets position, change drop down menu fixed position @ top...
any appreciated.
something this?
html
<div class="test">hello!</div>
jquery
$( window ).scroll(function() { offset = $('.test').offset(); if ( offset.top < $( window ).scrolltop() + 10 ){ $('.test').addclass('fixed'); } });
css
body{ height: 2000px; } .test{ position: relative; top: 100px; } .test.fixed{ position: fixed; top: 10px; }
Comments
Post a Comment