âš ī¸ Warning âš ī¸ Deprecated Code! This video tutorial contains outdated code.
💡 If you wish to update it, any AI assistant will update the code for you in seconds.

Peekaboo Box Tutorial Scroll Bottom CSS Transition Animation

Published : November 17, 2014   •   Last Edited : November 24, 2025   •   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){
	//win.style.webkitTransition = "right 0.7s ease-in-out 0s";
	win.style.transition = "right 0.7s ease-in-out 0s";
	win.style.right = "0px";
    } else {
	win.style.transition = "right 0.7s ease-in-out 0s";
	win.style.right = "-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>