Advertisement
tanaxmercedes

Show DIV on Scroll

Feb 2nd, 2021
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. ---------------- CSS:
  2.  
  3. .bottomtitle{
  4. position:fixed;
  5. font-size:50px;
  6. text-align:center;
  7. bottom:0;
  8. right:0;
  9. margin:0 50px 50px 0;
  10. color:{color:accent}!important;
  11. transition: all .5s;
  12. }
  13.  
  14. .hide {
  15. opacity:0;
  16. }
  17. .show {
  18. opacity:1;
  19. }
  20.  
  21.  
  22. ---------------- HTML:
  23.  
  24. <div id="myID" class="bottomtitle hide"><a href="/">{Title}</a></div>
  25.  
  26.  
  27. ---------------- SCRIPT:
  28.  
  29. <script>
  30. myID = document.getElementById("myID");
  31.  
  32. var myScrollFunc = function () {
  33. var y = window.scrollY;
  34. if (y >= 200) {
  35. myID.className = "bottomtitle show"
  36. } else {
  37. myID.className = "bottomtitle hide"
  38. }
  39. };
  40.  
  41. window.addEventListener("scroll", myScrollFunc);
  42. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement