A history of the Apple mouse in CSS

Wdd Logo.
October 24, 2013
A history of the Apple mouse in CSS.

thumbnailTake a look at this incredible Pen, it's an homage to how radically the Apple mouse has evolved over the years. Using a clever blend of CSS drawing and transitions, Josh Bader illustrates the beautiful simplicity of a device that — without giving a second glance — we use every single day.

Clicking through the different mice (how meta!) is nostalgic. It is reminiscent of a time when what was possible to accomplish with the peripheral was nowhere near as impressive as it is today. With apps like BetterTouchTool and Apple’s own operating system, we can interact with the mouse in ways that Doug Engelbart could never have imagined in 1963 (twenty years before the original Lisa Mouse).

Watching the seamless transitions between the different models reveals some peculiar similarities in the mice, and gives a sense of the mouse evolving. The apple logo, while not always given the same emphasis, is present in all of the designs. We begin to see the slow disappearance of the standard single-click interface in 1998 with the release of Apple’s USB Mouse (iMac Mouse in the pen).

By reusing all of the same basic elements, and applying transitioning styles to each one, the code is, like the subject matter, elegant and simple. Using just a handful of <i> elements with mouse-specific styles applied to each of them, Bader has created a unique work of art that can be appreciated by even those who may be less CSS-savvy.

mice_001

mice_002

mice_003

mice_004

mice_005

mice_006

mice_007

mice_008

How's it done?

As previously stated, each mouse reuses some of the same components. This allows the markup to be concise and the CSS to be structured in a logical way that is easy to read. Each mouse is represented by its own block similar to what is displayed below:

/* Name */
/* Shapes and Colors */
.name.mouse, .lisa.mouse .top { }
.name.mouse { }
.name.mouse .top { }
.name .cable, .lisa .cable i, .lisa .button { }
.name .cable { }

/* Common styles for all “cable” elements like side buttons or cable protectors */
.name .cable i { }

/* Handles size and positioning of “cable” elements */
.name .cable i:nth-child(1) { }
.name .cable i:nth-child(2) { width: 60px; height: 10px; top: 90px; left: -25px; }
.name .cable i:nth-child(3) { }
.name .cable i:nth-child(4) { }
.name .cable i:nth-child(5) { }

/* These are self-explanatory */
.name .button { }
.name .logo { }

I’ve stripped out the actual styles so that we can focus on the actual structure of the CSS. It’s actually not as complicated as one might think. If you’d like to dig into what styles are applied where, refer to the original source.

The shapes and colors are mostly accomplished using the border-radius property with Multiple Box-Shadows, while the actual size and placement of the mouse-specific elements is handled by the cable’s child elements.

Finally, with some clever Javascript, Bader updates the parent mouse class based on the list-item that the user clicks on:

$('li').on('click', function() {
var self = $(this);
$('.active').removeClass('active');
self.addClass('active');
self.closest('ul').attr('data-mouse', self.data('mouse') + ' mouse');
$('.mouse').removeAttr('class').addClass('mouse ' + self.data('mouse'));
});

Overall, this is very fun bit of code to play around with, even if just for the nostalgia. The patterns used here could easily be applied to other projects. It’s fascinating to see these projects come alive on a site like Codepen, and the open nature of the site means that anyone is able to fork this pen and change it in any way they see fit.

Have you tried drawing in just CSS? Which is your favorite Apple mouse? Let us know in the comments.

WDD Staff

WDD staff are proud to be able to bring you this daily blog about web design and development. If there's something you think we should be talking about let us know @DesignerDepot.

Read Next

3 Essential Design Trends, November 2024

Touchable texture, distinct grids, and two-column designs are some of the most trending website design elements of…

20 Best New Websites, October 2024

Something we’re seeing more and more of is the ‘customizable’ site. Most often, this means a button to swap between…

Exciting New Tools for Designers, October 2024

We’ve got goodies for designers, developers, SEO-ers, content managers, and those of you who wear multiple hats. And,…

15 Best New Fonts, September 2024

Welcome to our roundup of the best new fonts we’ve found on the web in the previous four weeks. In this month’s edition…

3 Essential Design Trends, October 2024

This article is brought to you by Constantino, a renowned company offering premium and affordable website design You…

A Beginner’s Guide to Using BlueSky for Business Success

In today’s fast-paced digital world, businesses are always on the lookout for new ways to connect with their audience.…

The Importance of Title Tags: Tips and Tricks to Optimize for SEO

When it comes to on-page SEO, there’s one element that plays a pivotal role in both search engine rankings and user…

20 Best New Websites, September 2024

We have a mixed bag for you with both minimalist and maximalist designs, and single pagers alongside much bigger, but…

Exciting New Tools for Designers, September 2024

This time around we are aiming to simplify life, with some light and fast analytics, an all-in-one productivity…

3 Essential Design Trends, September 2024

September's web design trends have a fun, fall feeling ... and we love it. See what's trending in website design this…

Crafting Personalized Experiences with AI

Picture this: You open Netflix, and it’s like the platform just knows what you’re in the mood for. Or maybe you’re…

15 Best New Fonts, August 2024

Welcome to August’s roundup of the best fonts we’ve found over the last few weeks. 2024’s trend for flowing curves and…