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.
Get Supercharged JavaScript Graphics now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.