Mindfly Website Design Studio

Mindfly Web Designer Favorite

Blog

Our Posts on Web Design

Diving in with CSS3 Awesome-ness: A Case Study

by Erica Quessenberry May 10, 2010 12:20 PM

I was recently assigned a project for a client who needed a very low-budget, no frills, *simple website that had little content. Not used to having a practically non-existent budget, I decided to view this project as a great opportunity to try out some new CSS3 goodness. Granted, most people viewing this site are probably not going to see the majority of the work I put into it, but I know it's there and so do Webkit-based users (Safari & Chrome), and, to some extent, so do Mozilla users. And everyone else, well, who cares. Onward and upward, I say.

We've been using some CSS3 styles here at Mindfly for awhile now, such as border radius and box/text shadows etc. But the new ones for me on this particular project were transitions and transforms, which I applied to the main navigation as seen in the image below. It took a bit of research and a bit of trial and error to get the styles in the right combinations on the right element to achieve what I was going for, but success I did have.

transitions example

The Tilt

My first goal was to rotate the list items so the appeared to be randomly tilted. Safari 4 and Firefox 3.5+ both have support for the :nth-child pseudo-selector. With this you can systematically target sibling elements that are even, odd, or much more. 

/* By default, I tilted all list items by -8 degrees */
.nav li {
transform: rotate(-8deg);
-moz-transform: rotate(-8deg);
-webkit-transform: rotate(-8deg); }

/* Rotate all even images 6 degrees */
.nav li:nth-child(even) {
transform: rotate(6deg);
-moz-transform: rotate(6deg);
-webkit-transform: rotate(6deg); }

/* Rotate every third item by -2 degrees */
.nav li:nth-child(3n) {
transform: rotate(-2deg);
-moz-transform: rotate(-2deg);
-webkit-transform: rotate(-2deg); }

/* Rotate every fourth item by 10 degrees */
.nav li:nth-child(4n) {
transform: rotate(10deg);
-moz-transform: rotate(10deg);
-webkit-transform: rotate(10deg); }

You can read more about :nth-child psuedo selectors here.

The Hover

For the hover effect, I wanted the tabs to slide out and away from the main content area. For that I once again used the transform property I used above to translate the elements 10px on the x-axis.

/* Pops the list item out to the right by 10px on hover */
.nav li a:hover {
transform: translateX(10px);
-webkit-transform: translateX(10px);
-moz-transform: translateX(10px); }

And finally, to add a little sexy-smoothness to the hover style as it slides out, I added a transition. This only works in Webkit browsers for now, but is supposed to be making an appearance in Firefox 3.7 and maybe the next version major version of Opera, as well, but who really knows with them sometimes.

/* Smooths out the transition (Webkit only) */
.nav li a {
transition: all 0.25s ease-out;
-webkit-transition: all 0.25s ease-out;
-moz-transition: all 0.25s ease-out; }

As you can see, I planned ahead for the changes to Opera and Firefox 3.7, by adding browser-specific lingo in, so once those browser support this property, I don't have to remember to go back and add it in.

The Final Details

/* Rounds the right-hand corners and adds a drop shadow */
.nav li a {
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
-moz-border-radius-topright: 10px;
-moz-border-radius-bottomright: 10px;
-webkit-border-top-right-radius: 10px;
-webkit-border-bottom-right-radius: 10px;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.6);
-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.6); }

And with this little bit of CSS3 magic, I have a sexy, sweet menu and an otherwise plain-jane site.

View the demo here. Obviously, for the full effect it should be viewed in either Safari or Chrome. However, each browser has it's own unique experience, so it's worth looking at in Firefox, Opera, and even Internet Explorer 8!

*The word 'simple' is generally not allowed here at Mindfly and will earn you from 1 - 10 pushups because nothing is ever as simple as people claim it will be.

Permalink | Comments (0) | Post RSSRSS comment feed

Please Don't Hurt the Web: Why I Love Firefox

by Janae Wiedmaier July 1, 2009 8:15 AM

When I started working here almost a year ago (only about 20 days to go until I hit that mark, yay!) we were just starting to implement moving into CSS3 styles on objects and really focusing on the differences between browser capabilities. We're all aware, whether it be through rants on this blog, on our personal blogs, or through very frustrated tweets, how much of a pain Internet Explorer 6 is when it comes to making websites functional in such an old browser. And, when I say functional, I mean just that. We don't even demand that our sites look the same (in fact, we often insist that they don't), but merely just work in that poor dying horse of a browser.

That said, this blog post isn't about ranting about IE6, no matter how easy it is to do.  What I really want to talk about is the fact that yesterday, Firefox 3.5 came out.  Here at Mindfly, we've been waiting with baited breath to see it (not only be a faster browser, which is their big selling point) implement some of the quirky things that other browsers have put into play or that they're taking onto themselves.

For some time now, we've been working with things like rounded corners that function in CSS3, but do not validate for CSS2, nor work in all browsers such as Internet Explorer.  However, with IE8 coming out a few months back, Safari 4 shortly before that, and now Firefox 3.5 yesterday, I really feel like browsers are moving forward into a new era of making my life easier.  Despite the fact that IE still doesn't support rounded corners.

I've been talking about typography for some time now and our options with it.  At first it was image replacement, @font-face, and sIFR.  More recently I discussed the awesome use of cufon.  Now I'm going to take a step back and say that thank heavens Firefox 3.5 has introduced support of @font-face.  Legality issues aside, as that's a can of worms on it's own, Firefox, Safari, and Internet Explorer (amazingly) users will now be able to view sites that use @font-face with no extra work included through javascript or flash.  There are rumors that Opera 10 will also be supporting this.  If you want tips on how to put @font-face into your site, Kyle has written a great blog post about it.  I am reminded, unfortunately, that one of my favorite browsers - Chrome - is not supporting @font-face.  Yet.  We can only hope that Google will implement it in the future (it can't be that hard, can it?  Safari is a webkit browser as well!).

What are some of the other things that Firefox is implementing for us designers out there?  You can get the full list at developer.mozilla.org, but my three favorites are:

  1. Text Shadow: No longer will we have to use image-replacement to get text shadows in Firefox!  Huzzah.
  2. Box Shadow: Since Safari and Chrome both support box shadow, it's nice to see Firefox jumping on the bandwagon and making it easier for us to add nice little shadows to items on our sites that aren't text.
  3. Improved Psuedo-Selectors: let me just say this (as it's only one of many) - :nth-child!  If all browsers supported this, my life would be complete.  I can't even count the times I have to select item 9 in a list of 13.

I'm looking forward to the chance to play around with all the new features and see how sites will render across browsers now and in the future.  I also have to give Mozilla a thumb's up for their continual work to allow us to easily make sites look gorgeous in their browser.  Between their support of plugins like firebug, the web developer toolbar, and colorzilla, I can't imagine trying to build a website without them.

Permalink | Comments (1) | Post RSSRSS comment feed