One of my favorite things to reflect upon when graced with a beautiful logo is… can it be done in CSS? The answer almost always, is yes.
Of course, just because you can build an aircraft carrier out of parts ordered from a 1979 Sears catalog, doesn’t mean it’s a good idea. The fun part is figuring out how to recreate a design with elegance.
A good example of elegance can be found in recreating the iconic 007 gun barrel. All we need is one HTML tag and a bit of CSS. Neat!
Set the body background color and add some basic style to the barrel div.
Add a nice curve to the front of our barrel.
border-bottom-right-radius: 26% 100%;
Create a :before pseudo element with a border-radius curve and move it to the top and left of its parent. Don’t worry if it seems too large and just focus on the overlapping area for now.
border-bottom-right-radius: 41% 100%;
Create a curvy :after pseudo element and move it to the bottom and right.
border-top-left-radius: 30% 109%;
border-top-left-radius: 60% 200%;
With everything lined up nicely; set the overflow property of .barrel to hidden to trim anything that wanders outside its shape.
Now set the background color of the pseudo elements to the same as the body. Perfection!
Recreating the 007 logo ranged from the ridiculously simple (zeros) to pleasingly complex (gun trigger/guard). The seven however, was especially difficult. It required multiple attempts to forge it into a shape that not only looked great in all browsers but retained its beauty when zoomed in or out.
Speaking of browsers, you’ll want to make sure you are using IE9 or any recent version of Chrome, FireFox or Safari.
Not having to worry about old browsers is a lovely benefit of working on personal projects. Well that and obsessing over pixel or even sub-pixel details for up to a week of time which is exactly what this project took.
Hope to see you in the theatres this November when James Bond returns in Skyfall.