Guest User

Parallax Code

a guest
Feb 28th, 2016
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <title>Scroll Effect</title>
  5. <style type="text/css">
  6. *{
  7. margin: 0;
  8. padding: 0;
  9. }
  10. #header {
  11. height: 150px;
  12. width: 100%;
  13. position: fixed;
  14. background: #ccc;
  15. transition:all 0.4s;
  16. }
  17. div {
  18. height: 2000px;
  19. }
  20. </style>
  21.  
  22. </head>
  23. <body>
  24. <header id="header">
  25.  
  26. </header>
  27. <div></div>
  28.  
  29. <script type="text/javascript">
  30.  
  31. function Scroll(){
  32. var top = document.getElementById('header');
  33. var ypos = window.pageYOffset;
  34. if(ypos > 587) {
  35. top.style.opacity = "0";
  36. }
  37. else{
  38. top.style.opacity = "1";
  39. }
  40. }
  41. window.addEventListener("scroll",Scroll);
  42.  
  43. </script>
  44. </body>
  45. </html>
Add Comment
Please, Sign In to add comment