A short time ago in a browser very, very close…

STAR WARStitles in CSS3

EPISODE IV
A NEW HOPE FOR CSS3

It is a period of vendor war.

This is a demonstration of Star Wars-style scrolling 3D titles in CSS3. It possibly has no practical purpose whatsoever but it looks great and you can impress your friends.

Before movie-buffs start ranting, I realize Star Wars wasn't the first to use crawling 3D titles, but few of you will remember the Flash Gordon series or the 1936 adaption of HG Wells' "Things to Come".

Also, by mentioning "Star Wars", everyone will understand what I mean. And I'll receive several thousand more visits.

The scrolling titles work well in Chrome, Safari and Firefox. Opera doesn't implement 3D transforms yet, but the text will scroll. IE users receive a blank page. A shame, but IE10 should support it.

So how does it work? Well, it's fairly simple. We have an outer absolute DIV (#titles) which is rotated along the X-axis using perspective to give the impression of depth. The same DIV also has an :after psuedo-element which applies a linear gradient so the text appears to fade out.

Inside, we have another absolutely-positioned DIV which contains the text (#titlecontent). The top is set to 100% to ensure it starts off-screen then uses CSS3 animation to move it upward over time. No JavaScript is required.

You will probably need to adjust the movement amount and timing depending on the quantity of text you want to show. The 3D depth can also be tweaked in the #titles declaration.

All the code is contained in this single HTML file…

View the source, Luke!

Sorry. Couldn't resist it.

You're welcome to use this demonstration code in your own sites. Please link back to the original article at:

sitepoint.com/
css3-starwars-scrolling-text/

and give me a shout on Twitter @craigbuckler – I'd love to see how you use and abuse it!

Finally, Han shot first and the original, unadulterated movies remain the best. Stop fiddling with them, George!