Telling you how we see the world.
I had previously created the Cadmus “post” button in Photoshop and it was essentially three images for the different states. I wanted to use this style for all our buttons, but doing it with single images is not a good idea. So I set about creating the same style of the buttons with CSS3. And this is what I ended up with.

I want to go into detail on the steps I took to create the button and the effects that make it work.
The whole idea is to use a combination of subtle effects to create a three dimensional object. Mike Rundle covers some of the ideas used here in his post about subtlety in interfaces. I’m hoping to expand a bit more on that. The idea is that:
Lets take a deeper look at the button and the various effects that we use to create this idea. The HTML used for the button is a bit excessive, but it will make sense when we go into detail.
<a class="button"><b class="o"><b class="m"><b>Post</b></b></b></a>
Now onto the styles.

a.button b.m { background: transparent url(button.png) repeat-x 0 0; }
a.button b.m { border-width: 1px; border-style: solid; border-color: #FFF rgba(255, 255, 255, 0.33) rgba(255, 255, 255, 0.33); }
a.button { border-width: 1px; border-style: solid; border-color: transparent transparent rgba(255, 255, 255, 0.63); }
a.button b.o { border: 1px solid rgba(0, 0, 0, 0.56); }
a.button b.m b { text-shadow: 0 1px 0 #DDD; color: #262626; }
I like adding hover states to my buttons and the simplest way is to lighten the background color of the button. For the active or mouse down state of the button the effect we are trying to achieve is that of a raised surface pressed inwards. Hence, the lighting of the button should reflect that. Now there are a couple of different ways to do this.

I like the idea where the surface is pressed in, but the top edge doesn’t move. Instead of having the entire button moving in, just the raised part gets pressed in. We go from a convex shape to a concave shape when it is pressed.
Lets look at it in detail again.

a.button:active b.m { background-position: 0 -160px; }
a.button:active b.m { border-color: rgba(255, 255, 255, 0.11) rgba(255, 255, 255, 0.23) rgba(255, 255, 255, 0.27); }
The result is a great looking button with CSS3. Below is a live demo of it tested on Firefox 3.6, Safari 4 and Chrome. On IE8 the rounded corners and active state are missing, and I haven’t tested it on Opera yet. If you do either of them, please ping me on Twitter and let me know.
Below is most of the CSS and here is the image sprite that is used. I use the yui reset CSS on the page so it might be a bit different for you.
a.button { text-decoration: none; border-color: transparent transparent #ECECEC; /** rgba fallback **/ border-color: transparent transparent rgba(255, 255, 255, 0.63); cursor: pointer; outline: none; } a.button:hover { text-decoration: none; } a.button, a.button b.o, a.button b.m { -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; border-width: 1px; border-style: solid; display: block; } a.button b.o { border-color: #5A5A5A; /** rgba fallback **/ border-color: rgba(0, 0, 0, 0.56); } a.button b.m { background: transparent url(button.png) repeat-x 0 0; border-color: #FFF transparent #C7C7C7; /** rgba fallback **/ border-color: #FFF rgba(255, 255, 255, 0.33) rgba(255, 255, 255, 0.33); } a.button:hover b.m { background-position: 0 -80px; } a.button:active b.m { background-position: 0 -160px; border-color: #B7B7B7 transparent #D4D4D4; /** rgba fallback **/ border-color: rgba(255, 255, 255, 0.11) rgba(255, 255, 255, 0.23) rgba(255, 255, 255, 0.27); } a.button b.m b { display: block; font-weight: bold; padding: 4px 8px; text-shadow: 0 1px 0 #DDD; color: #262626; /** Make the text unselectable **/ -moz-user-select: none; -webkit-user-select: none; }
I use the innermost b tag in some other buttons to add an icon to the background. The b.m tag is required because the alpha blending for the b.o border needs to have its own “layer”. Otherwise the b.o border would be on top of the background image and the shading would change according to it.
I am hoping that by going into the detail you can use these techniques in your designs and as Mike mentions in his post; think about your designs in 3D. It is less about using the specific border effects and more about using them together to achieve an overall look.
I would love to hear your feedback and comments; just catch me on Twitter.
Also, check out zurb’s super awesome CSS3 buttons. They have a take on CSS3 buttons and the buttons are super awesome!
Please do share this on .
I have received some really impressive feedback for this post. And I am glad that people have taken my ideas further and have done a great job with it. Here are some of the ones that I found. Please let me know on Twitter if I am missing some.
Thanks to @mliao for reading over this post.