Cover by Raffaele Cecco

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

O'Reilly logo

Chapter 3. Scrolling

Browser scrolling is the typically mundane action of moving scroll bars up and down or left and right. You use scrolling to move a viewport over content that is too long to view in its entirety within the confines of the browser window or designated browser element. In this chapter, we will examine more graphically creative uses of scrolling, initially from a purely CSS perspective, and then move on to more advanced scrolling effects that JavaScript makes possible.

Why even bother covering CSS scrolling in a book about JavaScript graphics? One reason is to highlight the limitations of using just CSS versus programmed effects in JavaScript. In addition, you can add some nice touches with just CSS, and those are worth investigating.

CSS-Only Scrolling Effects

CSS can provide some basic control of scrolling content, which you can use to good effect. In the atmospheric Retro Theater sample on the CSS Zen Garden website (Figure 3-1), the main website content within the cinema screen is surrounded by div elements that contain the cinema architecture images. As the user moves the browser’s vertical scroll bar, the main website content within the cinema screen (the viewport) is transformed into what appears to be black-and-white movie credits that move vertically.

This simple but effective use of CSS in Retro Theater by Eric Rogé creates a convincing scrolling cinema screen effect ()

Figure 3-1. This simple but effective use of CSS in Retro Theater by Eric Rogé creates a convincing scrolling ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required