Template:Kyoto/myScroll
From 2012.igem.org
(Difference between revisions)
(One intermediate revision not shown) | |||
Line 3: | Line 3: | ||
function setScroll(element) { | function setScroll(element) { | ||
element.css("position","relative"); | element.css("position","relative"); | ||
- | window. | + | $(window).scroll(function() { |
var parent = element.parent(); | var parent = element.parent(); | ||
var scroll_top = $(window).scrollTop(); | var scroll_top = $(window).scrollTop(); | ||
var off_top = parent.offset().top; | var off_top = parent.offset().top; | ||
var _top = scroll_top - off_top; | var _top = scroll_top - off_top; | ||
- | + | if(_top > 0) { | |
- | + | element.css("top",_top+"px"); | |
- | + | } else if (_top < 0) { | |
- | + | element.css("top","0px"); | |
- | + | } | |
- | }; | + | }); |
}</script> | }</script> | ||
</html> | </html> |
Latest revision as of 02:43, 26 September 2012