Created
October 10, 2017 17:03
-
-
Save 0xch4z/819ab2e5c68a8e66554e494c4b0d664b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
| <title>Document</title> | |
| </head> | |
| <body> | |
| <div id="wrapper"> | |
| <h1 id="message"> | |
| You're 0px from the top. | |
| </h1> | |
| </div> | |
| <style> | |
| @import url('https://fonts.googleapis.com/css?family=Quicksand'); | |
| * { | |
| margin: 0; | |
| padding: 0; | |
| text-align: center; | |
| font-family: 'Quicksand', Helvetica, Arial, sans-serif; | |
| } | |
| #wrapper { | |
| height: 200vh; | |
| background: #9e0; | |
| } | |
| h1 { | |
| color: #fff; | |
| position: fixed; | |
| top: 125px; | |
| width: 100%; | |
| } | |
| </style> | |
| <script> | |
| const msg = document.getElementById('message'); | |
| // function is called everytime the browser emits | |
| // a `scroll` event | |
| window.onscroll = function(event) { | |
| msg.innerText = 'You\'re ' + document.body.scrollTop + 'px from the top'; | |
| console.log('you\'re scrolling!'); | |
| console.log('event: ', event); | |
| } | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment