Now that our For A Beautiful Web workshops calendar is closed for the year, it was time to push live a redesign of that site with a focus on my new DVDs. This was a chance for me to play, both with HTML5 and CSS transforms and transitions to spice up the interface.
What? DVDs? You have DVDs? Oh, yes, I have! How kind of you to ask. “Designing with Microformats”, “Designing with CSS” and “Designing Web Accessibility”. I recorded them earlier this year. You can buy them via For A Beautiful Web. I'd like that.
The new For A Beautiful Web uses HTML5 because, well, why not? It also uses Modernizr, which is now an essential part of my toolkit of files. Modernizr helps me to use different CSS properties for browsers with different CSS handling capabilities and to design around their differences. The combination of HTML5, Modernizr and CSS3 is really making me passionate about designing for the web at the moment.
For A Beautiful Web’s home page has been making people smile with it’s spinning DVD discs, made possible by CSS transforms and transitions. As it stands at the moment these CSS properties are available if you use a Webkit-based browser, but during this week I will update the site to make them available to Firefox 3.6 users too.
First, the HTML. I marked up each DVD promo using a division, although the main action happens in the first anchor which contains two images and a heading.
<div id="promo-main-microformats">
<a href="#" title="Designing with Microformats">
<img src="cover.png" alt="Cover" />
<img src="disc.png" alt="Disc" />
<h3>Designing with Microformats</h3>
</a>
Etc.
</div>
Although the disc appears to be behind the cover, I chose to place it second in the source order because I felt that presented better if (for some reason to do with the apocalypse) CSS was unavailable.
Now the CSS. First I gave each division proportions and floated them left. I also added position:relative; to make each division a positioning context for its absolutely positioned children.
div#promo-main-microformats,
div#promo-main-css,
div#promo-main-accessibility {
position : relative;
float : left;
width : 240px;
padding : 320px 0 1.5em 0; }
Why the 320px top padding? Because the space that creates is just the right size to absolutely position the two promo images.
div.promo-main img[alt="Cover"] {
z-index : 2;
position: absolute;
top : 0;
left : 0; }
div.promo-main img[alt="Disc"] {
z-index : 1;
position: absolute;
top : 70px;
left : 85px; }
Notice the two z-index values? They allow me to place the DVD cover in front of the disc, even though that comes second in the source order.
That’s it (for any non-Webkit browser). Oh… you want shiny?
People using Webkit browsers are treated to a little easter egg to spice up their experience. CSS transforms and transitions, first proposed by Webkit, are now finding their way to Firefox and will be in version 3.6. Opera? Not yet (go on Opera engineers, I dare you). Internet Explorer? Probably not, but I can live with that.
First I rotated the images on :hover. The cover image by only -1 degree with an transform origin 50% horizontally and 100% vertically. The disc image was translated (moved) 40px to the right and rotated by 300% so that the DVD branding is visible when the transition stops.
.csstransforms div.promo-main a:hover img[alt="Cover"] {
-webkit-transform : rotate(-1deg);
-webkit-transform-origin : 50% 100%; }
.csstransforms div.promo-main a:hover img[alt="Disc"] {
-webkit-transform : translate(40px,0) rotate(300deg); }
To make the transforms happen smoothly, I added a transition duration of half a second that has a little inertia (ease-in-out) for a more natural result.
.csstransitions div.promo-main img[alt="Cover"],
.csstransitions div.promo-main img[alt="Disc"] {
-webkit-transition : all .5s ease-in-out; }
Shiny.
(Now, did I mention that you can buy my DVDs at For A Beautiful Web?)
3rd Nov 2009Could you please duplicate -webkit-properties with -o, -moz and without prefix for compatibility with other browsers? I mean Opera with Presto 2.4, Firefox 3.6 beta or any other *new* browsers.
So lovely! I have to say that I must of moused over the book cover a good 2 times.
(This comment was left on For A Beautiful Web)
3rd Nov 20093rd Nov 2009Love the new site Andy, it really is beautiful and the work you’ve done on the CD’s is truly amazing.
Awesome. Just awesome.
Lovely site update, Andy.I had just discovered the duelling regular/hover transitions and the power of it last week or so, though throwing in a rotate as well sure makes this wonderful!
Even cooler to me, in the study i was doing, is the webkit delay. As you may know, you can add a delay in seconds at the end of the transition rule. Changing it up for the hover or the regular provides interesting results.
Ordered.
Also, “a personally identifiable URL”? Is this site no longer using regular website urls, just twitter addresses? Oh.
(This comment was left on For A Beautiful Web)
3rd Nov 20093rd Nov 2009Works perfectly! Have to start playing with those “transitions”...
An absolutely amazing technique. I feel I may shamelessly rip it off in the future…
(This comment was left on For A Beautiful Web)
3rd Nov 2009wow!
Really nice effect! I’m so glad I re-discovered this website..
A small question: where does the
.csstransforms comes from? Modernizr?
(This comment was left on For A Beautiful Web)
3rd Nov 2009Inspiring bit of work that Andy. I can see why this has energised you. I’m very tempted to play with this kind of thing myself and that’s saying something with two very small kids at home giving me sleepless nights! Cheers for the write-up.
(This comment was left on For A Beautiful Web)
3rd Nov 2009Very nice! In my opinion images should be provided as-is on the interwebs, as opposed to photoshopping shadows, Polaroid borders and whatnot on them in advance, applying “cool” effects on them via CSS only.
Which brings me to my questions - why is the shadow on the DVD image on the actual image itself, and not on the disc?
(This comment was left on For A Beautiful Web)
3rd Nov 20093rd Nov 2009Ville Pekkarinen: Why is the shadow on the DVD image on the actual image itself, and not on the disc?
— You’re 100% correct, the border and shadow should be applied by CSS (in an ideal world). My problem, was that in testing I discovered that Safari 4 has a strange bug that flashed the border on and off for a brief moment when applying the transition. For speed of getting the site live, I used PNG images containing the border and shadow, although if the bug disappears I will go back to pure CSS.
Smirne: A small question: where does the .csstransforms comes from? Modernizr?
— Yes. Modernizr adds the .csstransforms class attribute value to the HTML element.
Luke Dorny: Is this site no longer using regular website urls, just twitter addresses?
— ExpressionEngine will accept any URL (not just a Twitter ID), but I prefer that people use a Twitter URL so I can see who they are. People who leave comments without a recognisable URL often get their comments deleted.
pepelsbey: Could you please duplicate -webkit-properties with -o, -moz and without prefix for compatibility with other browsers? I mean Opera with Presto 2.4, Firefox 3.6 beta or any other *new* browsers.
— I plan to add support for Firefox 3.6 this week (or next). Until the specification is further along I will hold out on providing the properties without a vendor prefix. Also, although Opera make a great browser, they are hardly progressive in implementing new or proposed CSS.
Unless the tell me otherwise, I can’t see transitions or transforms appearing in Opera anytime soon. (Come on Opera chaps, prove Malarkey wrong.)
3rd Nov 2009Andy Clarke, see http://www.opera.com/docs/specs/presto23/css/transitions/
3rd Nov 2009pepelsbey: I take everything back about Opera being non-progressive. Thanks for the link.
3rd Nov 2009Awesome, Andy. EE to the rescue!
Also, are you using multi-site ee? wondering since i see the same comments on both sites. ;)
3rd Nov 2009Luke Dorny: Are you using multi-site ExpressionEngine? Wondering since I see the same comments on both sites.
— Either that or I cut-and-paste comments across sites every time a new one comes in. You big donut ;) Actually I run EE Multiple Site Manager across three sites using a custom hack that EllisLab wrote for me that links to the site on which the comment was left.
Now that’s true Andy Clarke’s style I have known for years. Lovely! This is much better than earlier 2 versions. Color is cool, typography is beautiful, header with typekit’s skolar, markup-ed and styled using HTML-5 and CSS3. Amazing! Navigation is much more visible now. DVD presentation at homepage is classy. Footer seems better now with similar body color and pattern.
I really love the design. Awesome would be understatement :)
(This comment was left on For A Beautiful Web)
3rd Nov 2009Man, that is incredible. I love your imagination and application of modern web techniques. I looked at it in Safari 4 and IE 8. The fact that the site is beautiful in both but extra appealing in Safari is nothing short of inspirational.
Thanks.
(This comment was left on For A Beautiful Web)
3rd Nov 2009Really nice implementation! Need to start implementing the transitions to own designs.
(This comment was left on For A Beautiful Web)
3rd Nov 2009Loving the new lighter colours! One downside to my viewing pleasure. Is after the restyle, reading this blog on my iPhone have become almost impossible. The text-shadow used on the body copy makes it unreadable. Even when zooming in close.
I’ve taken a few screenshots to show this working:
http://michaelbragg.net/fabw/index.html
http://michaelbragg.net/fabw/index2.htmlThis is not so much of a problem to anybody who doesn’t use an iPhone, as they should use the handheld style sheet.
(This comment was left on For A Beautiful Web)
4th Nov 2009Love the new look Andy!
I’m trying to get a good grasp on html 5 and it helps me to see what others like yourself have done. One thing I’m curious about is why the ‘info’ DIV is not a FOOTER element instead… care to elaborate??
(This comment was left on For A Beautiful Web)
9th Nov 200926th Jan 2010a late one, but i only just stumbled across this. working lovely with the latest pre-release opera 10.50 version I’ve got hanging around here. look out for the beta, coming soon…(usual disclaimer: yes i work for opera)
An archive of blog entries since 2004 on subjects including CSS, web standards, accessibility, website design and development.