Create a 3D Animating Sidebar

By  on  
Chris Heilmann

Mozilla's Christian Heilmann is an evangelist that knows how to walk the walk as well as talk the talk.  You'll often see him creating sweet demos on his blog or the awesome Mozilla Hacks blog.  One of my favorite pieces from Christian isn't a demo but the 3D sidebar effect he users on his blog.  I took a moment to dissect the sidebar so I could show you how he does it!

It turns out Christian already wrote this post. Check his out when you get a moment!

The HTML

There are two elements involved in the sidebar effect:

<div class="sidebar">
	<div class="sidebar-rotater">
		<!-- sidebar content -->
	</div>
</div>

The parent element is used only for CSS perspective, which you will see below.

The CSS

A CSS transform is used to slant the sidebar and a transition is used to animate the sidebar to flat position upon hover:

.sidebar {
	perspective: 800px;
}
.sidebar-rotater {
	transform: rotateY(-25deg);
	transition: transform 1s;
}

.sidebar-rotater:hover {
	transform: rotateY(0deg);
}

The degree to which you rotate the sidebar is up to you but be sure not to over-rotate or you could be confusing users.

I think Chris' unique sidebar adds a touch of elegance to his site.  It's a shining example of doing something special without going overboard.  While you check out Christian's site to see his sidebar in action, take a few moments to read his posts -- you'll quickly see why he's a class act in our industry.

Recent Features

  • By
    I&#8217;m an Impostor

    This is the hardest thing I've ever had to write, much less admit to myself.  I've written resignation letters from jobs I've loved, I've ended relationships, I've failed at a host of tasks, and let myself down in my life.  All of those feelings were very...

  • By
    How I Stopped WordPress Comment Spam

    I love almost every part of being a tech blogger:  learning, preaching, bantering, researching.  The one part about blogging that I absolutely loathe:  dealing with SPAM comments.  For the past two years, my blog has registered 8,000+ SPAM comments per day.  PER DAY.  Bloating my database...

Incredible Demos

  • By
    Using Dotter for Form Submissions

    One of the plugins I'm most proud of is Dotter. Dotter allows you to create the typical "Loading..." text without using animated images. I'm often asked what a sample usage of Dotter would be; form submission create the perfect situation. The following...

  • By
    MooTools Image Preloading with Progress Bar

    The idea of image preloading has been around since the dawn of the internet. When we didn't have all the fancy stuff we use now, we were forced to use ugly mouseover images to show dynamism. I don't think you were declared an official...

Discussion

  1. Very effective, and done with minimal code.

  2. What browsers are supported?

  3. If you apply a transform: rotateZ(0); you’ll force the browser to use Hardware acceleration (tricking it into using a 3D render mode), providing a much smoother transition.

  4. Himanshu

    nice.,IE not supported otherwise all browsers are supported..

  5. Consider providing a quick explanation what the perspective: 800px declaration is doing, and why the position: relative declaration is needed. The rest of the code (the transition and transform properties) is straightforward.

    Just a small one-paragraph explanation please. Your readers should be educated about this stuff, otherwise they’ll just copy paste the code without actually understanding what the code does.

  6. Thanks .

    -webkit-transform: rotateY(130deg); /* Safari and Chrome */
    

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!