Template:Kyoto/js
From 2012.igem.org
(Difference between revisions)
Line 15: | Line 15: | ||
} | } | ||
$(function() { | $(function() { | ||
- | + | var element = $("#kyoto-menu"); | |
+ | element.css("position","relative"); | ||
+ | $(window).scroll(function() { | ||
+ | var parent = element.parent(); | ||
+ | if($(window).scrollTop() > parent.offset().top && (parent.height() + parent.position().top - 30) > ($(window).scrollTop() + element.height())) { | ||
+ | var scroll_top = $(window).scrollTop() - parent.offset().top; | ||
+ | element.css("top",scroll_top+"px"); | ||
+ | } else if ($(window).scrollTop() < (parent.offset().top)) { | ||
+ | element.css("top","0px"); | ||
+ | } | ||
+ | }); | ||
}); | }); | ||
</script> | </script> | ||
</html> | </html> |
Revision as of 17:23, 25 September 2012