3
2009
Matrix Animation with WebKit CSS3
I tweaked the WebKit CSS3 Animation example I made last time to create this “Matrix” animation for fun.
This is the screen capture of the animation on Safari 4.

You can try
the actual HTML page and see it working on current WebKit Nightly build or Safari 4.
To display the Katakana characters, I used @font-face rule to embed a Katakana dingbat-like font, rather than using an actual Japanese input.
Although I wanted display the kanakana vertically with using writing-mode: tb-rl, which I believe has been proposed for CSS2, this is not supported on Webkit so I had to use -webkit-transform to rotate each div to 90 degree to display vertically.
This way, each letter faces 90 deg angle too, but oh well, this Japanese letters are random, used only for visual purpose and don’t mean anything so I guess this doesn’t matter for now.
Let’s take a look at some of the CSS3 code, I am showing only important parts so if you would like to view the entire code, just open up the htmlpage and use Webkit’s inspector!
Embed A Katakana Font
@font-face {
font-family: Katakana;
src: url('MoonBeams-katakana_.TTF');
}
#matrix{
font-family: Katakana; /* use the embedded font */
position: absolute;
... (more styles here) ...
}
@font-face rule is not supported by older Safari including iPhone.
On supported browsers, you should be able to use either TrueType (.ttf) or OpenType (.otf).
Define Animations
@-webkit-keyframes fade{
0% {opacity: 1;}
100% {opacity: 0;}
}
@-webkit-keyframes fall{
from {top: -250px;}
to {top: 300px;}
}
I used both % and from/to keywords. But with %, you can define in-between state.
Rotate the Katakana Strings
#matrix div{
position: absolute;
top: 0;
-webkit-transform-origin: 0%;
-webkit-transform: rotate(90deg);
...
By setting -webkit-transform-origin as 0%, the div block rotates 90 degrees at the far left.
If you don’t set this, by default, it rotates at center axis.
…and Use the Defined Animations
#matrix div{
...
-webkit-animation-name: fall, fade;
-webkit-animation-iteration-count: infinite; /* use 0 to infinite */
-webkit-animation-direction: normal; /* default is normal. use 'alternate' to reverse direction */
-webkit-animation-timing-function: ease-out;
}
For more detailed info on -webkit-animation properties, read Apple’s Developer Connection
Again, this example is currently working only on the latest WebKit and Safari 4 (not iPhone).
Google Chrome does not support @font-face or animation. (-webkit-transform:rotate... works), and I assume it does not work on Android either.
(And I have no intention to try on other WebKit-base browsers like S60).
49 Comments to “Matrix Animation with WebKit CSS3”
Leave a comment
Recent Posts
- Touchy-Feely with DOM Events: Rethinking Cross-Device User Interaction
- My Mobile HTML5 Talks Slides
- How to Enable WP8 Emulator on Mac
- HTML5 Form Validation のカスタマイズ
- HTML5 Dev Conf Slides
- HTML5 File API & XHR2 with Node.js Express
- Because I Want Mobile Web to Be A Better Platform
- Resolution in Media Queries
- HTML5: The Mobile Approach
- Creating Non-disruptive Notifications with HTML5
- Making Chupa-Chups using CSS3 Pseudo-elements
- Quick Fun: CSS3 Filter Effects
- The Day I seized The InterWeb – HTTP Status Cats
- HTML5 Form Field Validation with CSS3
- HTML5 Input Event Handlers and User-Experience
- Creating Usable Enyo UI – Buttons and Interactive Dialogs
- Thank you, Steve!
- Five CSS tricks used in Enyo JS Framework, and you can try them too!
- Open Web Camp III
- Quick Demo: CSS3 Fancy Avatar








correction – for “fall” animation, you should use translate, instead of position. (e.g. top to bottom movement should be used with -webkit-translateY).
smfr from Apple gave me this tip a while ago and forgot to correct on my blog. sorry!!!
[...] The Matrix [...]
It doesn’t work on my Firefox 3.5.7 for Mac
yeah, this demo is only for WebKit-based browsers because mozilla browsers do not support the animation with keyframes!
[...] 黑客帝国:教程 | 演示地址 [...]
[...] The Matrix [...]
Sorry guys I know it sucks but this is Webkit-only (Safari, Chrome etc.) demo.
Nice example. Love a bit of the Matrix.
just checked with a forked version of chrome (iron) on windows, worked as expected (webkit 532.8)
[...] Matrix Animation with Webkit CSS3 | Demo This one is pretty cool. If you are a fan of Matrix, check out this example. [...]
[...] falling symbols display of the Matrix in encoded form has been recreated in CSS3 by GirlieMac!. It uses the WebKit CSS3 animation properties, plus she’s also used @font-face to pull in a [...]
[...] [...]
Stumbled this blog post, bless you.
Matches the screen shot in Chrome 5.0.375.6 dev
Very nice. It does work in Chrome on Windows.
It works in android too (HTC Hero).
Awesome! I don’t have an Android running device to test for myself! Thanks for letting me know.
[...] The Matrix – Create cool and effective matrix-like animation with CSS3! It is a good example how CSS3-based animations can work! [...]
Good! and it works also on Chorme on Ubuntu!
Very Nice! If the alpha could change per character, it would almost look authentic!
[...] Here is a demo featuring a Matrix type effect using some CSS3. I didn’t have any luck viewing this one in Firefox, but it worked just fine in Chrome. Find out more about this demo here. [...]
[...] 11. Matrix Animation with WebKit CSS3 [...]
[...] http://girliemac.com/blog/2009/05/03/matrix-animation-with-webkit-css3/ [...]
[...] 34.“Matrix” Animation with CSS3 on WebKit [...]
[...] Matrix Animation With WebKit CSS3 [...]
[...] 11. Matrix Animation with WebKit CSS3 [...]
Tilted Katakana …
[...] Matrix Animation with WebKit CSS3 [...]
You can now do this with firefox 5.0.
http://www.squrk.com/perma/matrix/
[...] Matrix Animation With WebKit CSS3 [...]
[...] 12. Matrix Animation with WebKit CSS3 [...]
[...] Matrix Animation with WebKit CSS3 [...]
It works in Firefox as well,, check the code and replace in the CSS content wherever u find -webkit to -moz. So that it works in FF and chrome as well
enjoy.
[...] 8. Matrix Animation with WebKit CSS3 [...]
Works on android thrive tablet…but a bit slow/chunky. Might be connection I am on. Sweet work!
[...] [...]
[...] Matrix [...]
[...] Matrix [...]
[...] 15. Эффект Матрицы [...]
[...] Matrix [...]
[...] Matrix [...]
[...] Matrix [...]
[...] Matrix [...]
[...] Matrix [...]
[...] Matrix [...]
[...] Matrix [...]
[...] Matrix [...]
[...] Matrix Animation with WebKit CSS3 [...]
[...] Matrix [...]