Line 5: | Line 5: | ||
<html lang="en"> | <html lang="en"> | ||
+ | |||
+ | <script> | ||
+ | window.smoothScroll = function(target) { | ||
+ | var scrollContainer = target; | ||
+ | do { //find scroll container | ||
+ | scrollContainer = scrollContainer.parentNode; | ||
+ | if (!scrollContainer) return; | ||
+ | scrollContainer.scrollTop += 1; | ||
+ | } while (scrollContainer.scrollTop == 0); | ||
+ | |||
+ | var targetY = 0; | ||
+ | do { //find the top of target relatively to the container | ||
+ | if (target == scrollContainer) break; | ||
+ | targetY += target.offsetTop; | ||
+ | } while (target = target.offsetParent); | ||
+ | |||
+ | scroll = function(c, a, b, i) { | ||
+ | i++; if (i > 30) return; | ||
+ | c.scrollTop = a + (b - a) / 30 * i; | ||
+ | setTimeout(function(){ scroll(c, a, b, i); }, 20); | ||
+ | } | ||
+ | // start scrolling | ||
+ | |||
+ | |||
+ | </script> | ||
+ | |||
+ | |||
<cfheader name="X-XSS-Protection" value="1"> | <cfheader name="X-XSS-Protection" value="1"> | ||
Line 37: | Line 64: | ||
+ | |||
+ | <div class="first"><button type="button" onclick="smoothScroll(document.getElementById('second'))"><img src="https://static.igem.org/mediawiki/2017/8/8c/T--William_and_Mary--arrowright.jpeg" height = "80"/></button></div> | ||
+ | <div class="second" id="second">Hi</div> | ||
− | |||
− | |||
− | |||
<div style='position:fixed; top:40%; right:3%;'> | <div style='position:fixed; top:40%; right:3%;'> |
Revision as of 01:45, 2 October 2017