Although CSS isn’t that difficult, useful CSS techniques are not easy to find. Sometimes finding a cross-browser solution might take time, but you don’t have to reinvent the wheel every single time. Other designers may have had the same problem in the past and thus the main goal of this round-up is to share with you a goldmine of new techniques which you will hopefully find very useful and valuable. We also hope that these tutorials and articles will help you solve common design problems and find new ways of approaching tricky CSS issues.
The main goal of the article is to present powerful new CSS techniques, encourage experimentation in the design community and push CSS forward. Please notice that we feature both experimental demos and practical techniques in this article. Next week we will present even more useful new tools and resources for front-end developers. We sincerely appreciate the efforts of the design community — thank you, guys!
Interesting and Original Techniques Link
Wonder-Webkit: 3D Transforms1
This is a remarkable example of what can be done using CSS3 3D transformations. The interesting stuff is the possibility of manipulate the transformation matrix of any element of the DOM, In this case we get the matrix given only the four end points of the element. Don’t forget to click on the items, too. Who thought a couple of years ago that something like that would be possible with only CSS?
CSS Box Shadow and Text Shadow Experiments3
text-shadow allow us to create some pretty cool design elements that don’t even look like shadows. The key is to think about how CSS shadows work and use them to get the desired effect. The article features three remarkable examples of using
box-shadow property creatively to achieve effects that don’t have much to do with shadows.
CSS3 Depth of Field5
Sawyer Hollenshead’s experiment is an attempt to create the “Depth of Field” effect with CSS. The blurry text is accomplished using
text-shadow, with the text color set to
transparent. Take a look at the demo6 and don’t forget to press ‘n’ to toggle animation.
Art Deco Selectable Text8
This is a quick proof-of-concept of split typography, based on Pierre Fix-Masseau’s Art Deco style. The challenge was to have this kind of ‘split letters’ as part of a web page layout, while retaining the ability to select text.
<a>s on top of each other and then disable pointer-events for the top
About War and Bananas
This student project explores new ways of styling and designing websites in an artistic way. The students from Merz Akademie in Germany used Picasso’s “Guernica” as the footage, seperated the picture into different layers and animated them using CSS.
This is a quick CSS3 experiment trying to replicate the Dock of OS X, complete with labels, animations, reflections and indicators. It uses CSS transitions for the magnification effect and the
:target pseudo-class and CSS animations for the bouncing effect.
An interesting experiment by Andrew Hoyer. The walking man is implemented using only CSS3 animations and simple HTML. The key idea behind all of this is the fact that a CSS transformation applied to an element also applies to all of its children. Works in Webkit-browsers only.
Type study: An all CSS button18
Dan Cederholm explains how through the use of
border-radius, and CSS gradients, we can create a highly polished three-dimensional, responsive button that doesn’t require images.
This technique uses multiple
text-shadows to create a 3D appearance of the text on any HTML element. No extra mark-up is used. Works in the latest builds of Safari, Chrome, Firefox, and Opera.
Spin those Icons with CSS3
Tom Kenny features a neat effect which spins the social icons with the help of a CSS transforms and transition when you hover over them. A very nice enhancement.
The Shapes of CSS22
The article presents various geometrical forms, all created using CSS and a single HTML element. The following forms are presented: square, rectangle, circle, oval, triangle, parallelogram, trapezoid, star, pentagon, hexagon, octagon, heart and infinity — all using CSS only.
CSS background image hacks24
Emulating background image crop, background image opacity, background transforms, and improved background positioning. The article explains a few hacks relying on CSS pseudo-elements to emulate features unavailable or not yet widely supported by modern browsers.
Making Better Select Elements with CSS3 and jQuery26
This tutorial explains how to take an ordinary
select element, and replace it with a better looking version, while keeping all the functionality intact. It uses CSS3 multiple background and a transparent PNG image as a sprite. Currently, multiple backgrounds are supported by Firefox, Safari, Chrome and Opera. For Internet Explorer and older versions of the first browsers, a fallback is defined, which is basically just a regular version of the background. When parsing the CSS document, browsers that do not understand multiple background will just ignore the rule and use the plain one.
CSS-Only 3D Slideshow28
:focus pseudo-class and the HTML5 element
Animated CSS3 Owl32
“What about having an owl that moved his eyes every so often and when hovered over would raise his wings while a few light rays would spin in the background. A little excessive? Probably. Necessary? Not at all. However, that’s exactly what I was looking to do with CSS3 transforms, transitions, and animations.” An interesting experiment, best viewed in Safari or Chrome.
Rotating color cube box with CSS3 animation, transforms and gradients36
A yet another remarkable experiment that presents a rotating color cube using CSS3 animations and transforms. Be aware that the browser may slow down a bit when loading the demo.
CSS3 Demo: 3D Interactive Galaxy38
A CSS3 demo where you can interact with a procedurally generated 3D galaxy. In order to create the effect, the designer used 3D CSS properties available in Safari 5 and on the iPhone and iPad.
Getting Hardboiled with CSS3 2D Transforms40
Andy Clarke explains how to use CSS3 two-dimensional transforms to add realism to a row of hardboiled private detectives’ business cards. The working demo is available as well.
How to create Microsoft Office Minibar with jQuery and CSS342
Janko Jovanovic explains how to create a Microsoft Office Minibar that exposes context-related functionality. In case of MS Word, context is a text selection. Since Minibar always pops up near the mouse pointer it enables users to quickly perform actions related to a selection.
Rotating Feature Boxes46
Pure CSS3 box-shadow page curl effect
Okay, the CSS3 code here is quirky and might seem a bit bloated first, but it’s a nice example of using various CSS3 features together to create an effect that would usually require images.
Pure CSS Folded-Corner Effect48
Learn how to create a simple CSS folded-corner effect without images or extra markup. It works well in all modern browsers and is best suited to designs with simple colour backgrounds; supported by Firefox 3.5+, Chrome 4+, Safari 4+, Opera 10+, IE 8+.
Useful Practical Techniques Link
New @Font-Face Syntax: Simpler, Easier
With IE9 and FF4 nearing release, Ethan Dunham from Font Squirrel has revisited the problem of a cross-browser CSS @font-face syntax and found a new and simpler solution. In this article, Richard Fink explains the new syntax and its variations and suggests the most reasonable syntax to use. Also, check FontSpring’s The New Bulletproof @font-face Syntax54. Please notice that this technique no longer works in Internet Explorer 9.
The New Clearfix Method55
The clearfix hack, or “easy-clearing” hack, is a useful method of clearing floats. The original clearfix hack56 works great, but the browsers that it targets are either obsolete or well on their way. The new clearfix method applies clearing rules to standards-compliant browsers using the
:after pseudo-class. For IE6 and IE7, the new clearfix method triggers
hasLayout with some proprietary CSS. Thus, the New Clearfix method effectively clears floats in all currently used browsers without using any hacks.
Breadcrumb Navigation with CSS Triangles59
This article describes a fairly simple technique for creating triangles with pure CSS. You just make a block level element with zero width and height, a colored border on one side, and transparent borders on the two adjacent sides. Useful for little arrow sticking out from speech bubbles, navigation pointers, and more.
Responsive Images: Experimenting with Context-Aware Image Sizing61
Since Ethan Marcotte coined the term, responsive Web design has gained a lot of attention in the Web design community, mainly due to its remarkable potential for flexible layouts that respond to the browser’s viewport for the best user experience. The main problem with such designs, however, is figuring out how to serve small images to mobile devices and tablets and large ones to desktop displays. The goal of this technique is to deliver optimized, contextual image sizes for responsive layouts that utilize dramatically different image sizes at different resolutions.
CSS powered ribbons the clean way63
Harry Roberts presents a simple technique that uses an image and CSS to create clean ribbons. This technique creates a white
<h2> with a pink background, pulls the <h2> out of the content area with a negative margin and then places the image absolutely left-bottom of the
<h2> in a
Create a centred horizontal navigation65
Centring block level elements is easy, just define a
width and set
margin: 0 auto;, but what if you don’t know that fixed width? You could use
text-align: center;, but that won't work on 100%-width block-level elements either. However, there is a way to have a centred horizontal navigation without knowing an explicit width, and without adding CSS.
Keep Margins Out of Link Lists66
When building a menu or other list of links, it's generally a good practice to use
display: block; or
display: inline-block; so that you can increase the size of the link target. The simple truth: bigger link targets are easier for people to click and lead to better user experience. Make sure list items don't have padding, but links do and don't use margins, so there are no un-clickable gaps.
Styling children based on their number, with CSS371
Lea Verou presents an interesting technique for styling children based on their number. It is based on the relationship between
:nth-last-child. With the technique, the number of total rules is still O(N), but the number of selectors in every rule becomes just 2, making this trick practical for far larger numbers of children.
Wrapping Long URLs and Text Content with CSS73
To wrap long URLs, strings of text, and other content, it's enough to apply a carefully crafted chunk of CSS code to any block-level element (e.g., perfect for
<pre> tags). Very useful for cases when code snippets need to be presented in a blog post with a fixed content width.
Pure CSS(3) accordion
An interesting accordion technique that uses nothing but semantic HTML, CSS and some progressive CSS3. There are also two versions, a horizontal one and a vertical one.
Rein In Fluid Width By Limiting HTML Width76
If you are making a fluid width site but wish to limit the maximum width it can expand, you can do so easily by literally applying a
max-width to the
html element. Quick and useful tip.
Inline Boxes with Bottom Alignment78
Imagine that you want to keep a "Submit" button at the bottom of a line box, aligned with form controls positioned below their label (see below). If the containing block is not wide enough for the "Submit" button to flow next to the other controls, that button must be displayed at the beginning of the next line box with minimal space above it. The article explains a solution for this problem.
Transparent CSS Sprites80
The idea of the technique is to create a transparent sprite allowing the
background-color to show through. If you are familiar with CSS Sprites, you should be able to grasp this twist relatively easily. Simply, an image with a transparent “knocked-out” transparent center is placed over a background colour. Changing the background colour changes the appearance of the element.
Jump links and viewport positioning81
"Using within-page links presses the jumped-to content right at the very top of the viewport. This can be a problem when using a fixed header. With a bit of hackery, there are some CSS methods to insert space between the top of the viewport and the target element within a page."
Mimic Equal Columns with CSS3 Gradients83
"What happens when your main content area needs two specific background colors: one for the primary content, and another for the sidebar? If you’ve ever tried applying the background to each container itself, you’ll no doubt have realized that your layout quickly becomes fragmented as soon as the primary content section exceeds the height of the sidebar. Generally, the solution is to set a background image on the parent element, and set it to repeat vertically. However, if we get clever with CSS3 gradients, we can achieve the same effect with zero images." A nice piece by Jeffrey Way.
Double Click in CSS84
Center Multiple DIVs with CSS86
At some point, you may have a situation where you want to center multiple elements (maybe
«div» elements, or other block elements) on a single line in a fixed-width area. Centering a single element in a fixed area is easy. Just add
margin: auto and a fixed width to the element you want to center, and the margins will force the element to center. You can achieve something similar by taking advantage of CSS’s flexibity with “recasting” elements.
Clearing Floats with Overflow88
One of the common problems we face when coding with float-based layouts is that the wrapper container doesn't expand to the height of the child floating elements. The typical solution to fix this is by adding an element with clear float after the floating elements or adding a clearfix to the wrapper. But you can also use the
overflow property to fix this problem. It's not a new trick, but still very useful.
Different Transitions for Hover On / Hover Off90
The idea of this technique is to solve an interesting problem: what about using different transition for hover on and off? In the example, when you hover over, the
:hover transition overrides the transition set in the regular state, and that property animates. When you hover off, the transition from the regular state takes over and that property animates. Useful.
Stretch a Box to its Parent's Bounds91
A powerful feature that enables absolute positioning of stretching a box. The most popular use is having a box positioned in either
Equal Height Column Layouts with Borders and Negative Margins in CSS92
This article demonstrates different construct techniques and brushes up on a few concepts you might have missed.
Using CSS Text-Shadow to Create Cool Text Effects94
The CSS3 text-shadow property has been around for some time now and is commonly used to recreate Photoshop's Drop Shadow type shading to add subtle shadows which help add depth, dimension and to lift an element from the page. A demo is available if you'd like to see what it looks like before you give it a try yourself.
Fluid Width Equal Height Columns96
Equal height columns have been a need of web designers forever. If all the columns share the same background, equal height is irrelevant because you can set that background on a parent element.
It's always nice to be able to add a vignetting effect to photos sans-Photoshop, but the way browsers interpret box-shadow:inset is to throw the shadow behind the image, rendering it invisible. While this seems pretty useless, it does make sense when you consider other kinds of content.
A very nice hover effect: the Twitter icon has a circle as a background and the circle increases its radius when the users hovers the mouse over it.
Last Click Link
CSS 3D Scrolling @ BeerCamp at SXSW 2011104
Now, that's innovative: while you are scrolling down the page, the site appears to have a 3D scrolling effect. And it has a nice Inception reference. Can you discover it?
50 New Useful CSS Techniques, Tutorials and Tools106
The previous round-up of CSS techniques on Smashing Magazine. In this post we present recently released CSS techniques, tutorials and tools for you to use and enhance your workflow, thus improving your skills.
- 1 http://www.is-real.net/experiments/css3/wonder-webkit/
- 2 http://www.is-real.net/experiments/css3/wonder-webkit/
- 3 http://www.zurb.com/playground/css-boxshadow-experiments
- 4 http://www.zurb.com/playground/css-boxshadow-experiments
- 5 http://forrst.com/posts/CSS3_Depth_of_Field-4zh
- 6 http://shakenandstirredweb.com/playground/blur/
- 7 http://forrst.com/posts/CSS3_Depth_of_Field-4zh
- 8 http://manufacturaindependente.com/colorfont/
- 9 http://manufacturaindependente.com/colorfont/
- 10 http://onotakehiko.com/webkitclock/
- 11 http://onotakehiko.com/webkitclock/
- 12 http://www.designmadeingermany.de/slideshow/#a1
- 13 http://www.designmadeingermany.de/slideshow/#a1
- 14 http://michaelhue.com/cssdock/
- 15 http://michaelhue.com/cssdock/
- 16 http://www.andrew-hoyer.com/experiments/walking/
- 17 http://www.andrew-hoyer.com/experiments/walking/
- 18 http://blog.typekit.com/2011/02/10/type-study-an-all-css-button/
- 19 http://blog.typekit.com/2011/02/10/type-study-an-all-css-button/
- 20 http://markdotto.com/playground/3d-text/
- 21 http://markdotto.com/playground/3d-text/
- 22 http://css-tricks.com/examples/ShapesOfCSS/
- 23 http://css-tricks.com/examples/ShapesOfCSS/
- 24 http://nicolasgallagher.com/css-background-image-hacks/
- 25 http://nicolasgallagher.com/css-background-image-hacks/
- 26 http://tutorialzine.com/2010/11/better-select-jquery-css3/
- 27 http://tutorialzine.com/2010/11/better-select-jquery-css3/
- 28 http://net.tutsplus.com/tutorials/html-css-techniques/build-a-kickbutt-css-only-3d-slideshow/
- 29 http://net.tutsplus.com/tutorials/html-css-techniques/build-a-kickbutt-css-only-3d-slideshow/
- 30 http://www.sohtanaka.com/web-design/css-border-tricks-tutorial/
- 31 http://www.sohtanaka.com/web-design/css-border-tricks-tutorial/
- 32 http://www.shayhowe.com/tutorial/css3-animated-owl-tutorial/
- 33 http://www.shayhowe.com/tutorial/css3-animated-owl-tutorial/
- 34 http://blog.bloop.co/33827558
- 35 http://blog.bloop.co/33827558
- 36 http://css-class.com/test/css/3/transform-color-cube3.htm
- 37 http://css-class.com/test/css/3/transform-color-cube3.htm
- 38 http://www.zachstronaut.com/posts/2010/07/28/3d-css3-galaxy.html
- 39 http://www.zachstronaut.com/posts/2010/07/28/3d-css3-galaxy.html
- 40 http://blog.typekit.com/2011/01/25/case-study-getting-hardboiled-with-css3-2d-transforms/
- 41 http://blog.typekit.com/2011/01/25/case-study-getting-hardboiled-with-css3-2d-transforms/
- 42 http://www.jankoatwarpspeed.com/post/2010/05/23/microsoft-office-minibar-jQuery-CSS3.aspx
- 43 http://www.jankoatwarpspeed.com/post/2010/05/23/microsoft-office-minibar-jQuery-CSS3.aspx
- 44 http://cssglobe.com/post/9392/angled-content-mask-with-css
- 45 http://cssglobe.com/post/9392/angled-content-mask-with-css
- 46 http://css-tricks.com/rotating-feature-boxes/
- 47 http://css-tricks.com/rotating-feature-boxes/
- 48 http://nicolasgallagher.com/pure-css-folded-corner-effect/
- 49 http://nicolasgallagher.com/pure-css-folded-corner-effect/
- 50 http://www.elated.com/articles/smooth-fading-image-captions-with-pure-css3/
- 51 http://www.elated.com/articles/smooth-fading-image-captions-with-pure-css3/
- 52 http://css-tricks.com/fade-image-within-sprite/
- 53 http://css-tricks.com/fade-image-within-sprite/
- 54 http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax
- 55 http://perishablepress.com/press/2009/12/06/new-clearfix-hack/
- 56 http://perishablepress.com/press/2008/06/18/css-hackz-series-clearing-floats-with-the-clearfix-hack/
- 57 http://perishablepress.com/press/2009/12/06/new-clearfix-hack/
- 58 http://net.tutsplus.com/tutorials/html-css-techniques/quick-tip-mimic-a-click-event-with-css/
- 59 http://css-tricks.com/triangle-breadcrumbs/
- 60 http://css-tricks.com/triangle-breadcrumbs/
- 61 http://filamentgroup.com/lab/responsive_images_experimenting_with_context_aware_image_sizing/
- 62 http://filamentgroup.com/lab/responsive_images_experimenting_with_context_aware_image_sizing/
- 63 http://csswizardry.com/2011/02/css-powered-ribbons-the-clean-way/
- 64 http://csswizardry.com/2011/02/css-powered-ribbons-the-clean-way/
- 65 http://csswizardry.com/2011/01/create-a-centred-horizontal-navigation/
- 66 http://css-tricks.com/keep-margins-out-of-link-lists/
- 67 http://css-tricks.com/keep-margins-out-of-link-lists/
- 68 http://cssglobe.com/post/9435/pure-css3-post-tags
- 69 http://playground.deaxon.com/css/tag-shape/
- 70 http://cssglobe.com/post/9435/pure-css3-post-tags
- 71 http://leaverou.me/2011/01/styling-children-based-on-their-number-with-css3/
- 72 http://leaverou.me/2011/01/styling-children-based-on-their-number-with-css3/
- 73 http://perishablepress.com/press/2010/06/01/wrapping-content/
- 74 http://perishablepress.com/press/2010/06/01/wrapping-content/
- 75 http://perishablepress.com/press/2010/10/20/target-iphone-and-ipad-with-css3-media-queries/
- 76 http://css-tricks.com/limit-html-width/
- 77 http://css-tricks.com/limit-html-width/
- 78 http://www.yuiblog.com/blog/2010/11/15/inline-boxes-with-bottom-alignment/
- 79 http://www.yuiblog.com/blog/2010/11/15/inline-boxes-with-bottom-alignment/
- 80 https://www.smashingmagazine.com/2010/10/31/transparent-css-sprites/
- 81 http://nicolasgallagher.com/jump-links-and-viewport-positioning/
- 82 http://nicolasgallagher.com/jump-links-and-viewport-positioning/
- 83 http://net.tutsplus.com/tutorials/html-css-techniques/quick-tip-mimic-equal-columns-with-css3-gradients/
- 84 http://css-tricks.com/double-click-in-css/
- 85 http://css-tricks.com/double-click-in-css/
- 86 http://www.impressivewebs.com/center-multiple-divs/
- 87 http://www.impressivewebs.com/center-multiple-divs/
- 88 http://www.webdesignerwall.com/tutorials/css-clearing-floats-with-overflow/
- 89 http://www.webdesignerwall.com/tutorials/css-clearing-floats-with-overflow/
- 90 http://css-tricks.com/different-transitions-for-hover-on-hover-off/
- 91 http://devign.me/css-stretch-a-box-to-its-parent-bounds/
- 92 https://www.smashingmagazine.com/2010/11/08/equal-height-columns-using-borders-and-negative-margins-with-css/
- 93 https://www.smashingmagazine.com/2010/11/08/equal-height-columns-using-borders-and-negative-margins-with-css/
- 94 http://line25.com/articles/using-css-text-shadow-to-create-cool-text-effects
- 95 http://line25.com/articles/using-css-text-shadow-to-create-cool-text-effects
- 96 http://css-tricks.com/fluid-width-equal-height-columns/
- 97 http://css-tricks.com/fluid-width-equal-height-columns/
- 98 http://trentwalton.com/2010/11/22/css-box-shadowinset/
- 99 http://trentwalton.com/2010/11/22/css-box-shadowinset/
- 100 http://playground.deaxon.com/css/flex-nav/
- 101 http://playground.deaxon.com/css/flex-nav/
- 102 http://media.miekd.com/css3memory/
- 103 http://media.miekd.com/css3memory/
- 104 http://2011.beercamp.com/
- 105 http://2011.beercamp.com/
- 106 https://www.smashingmagazine.com/2010/10/12/50-new-useful-css-techniques-tutorials-and-tools/
- 107 https://www.smashingmagazine.com/2010/10/12/50-new-useful-css-techniques-tutorials-and-tools/
Hold on tiger! Thank you for reading the article. Did you know that we also publish printed books and run friendly conferences – crafted for pros like you? Like SmashingConf Oxford, on March 15—16, with smart design patterns and front-end techniques.