Peekaboo Box Tutorial Scroll Bottom CSS Transition Animation

Published :
Author :
Adam Khoury
Learn to program animated HTML Peekaboo boxes using CSS transitions that are triggered using only one line of JavaScript. The Peekaboo box can animate into the web page at any desired scroll point. A good understanding of scroll event programming in JavaScript enabled me to write this functionality in just a few minutes. <!DOCTYPE html> <html> <head> <style> div#peekaboo{ position:fixed; bottom:0px; right:-352px; background: #C4E6FF; padding:25px; width:300px; height:200px; font-size:48px; } </style> <script> function yScrollHandler(){ var win = document.getElementById("peekaboo"); if((window.pageYOffset + window.innerHeight) >= document.body.offsetHeight){ // = "right 0.7s ease-in-out 0s"; = "right 0.7s ease-in-out 0s"; = "0px"; } else { = "right 0.7s ease-in-out 0s"; = "-452px"; } } window.onscroll = yScrollHandler; </script> </head> <body> <h2>Scroll Bottom Y Handler Function</h2> <p style="height:1600px; font-size:18px;"> Scroll to the bottom of the page to see a Peekaboo box effect &darr; </p> <div id="peekaboo">Peekaboo!</div> </body> </html>