CSS3: Possibilities, Best Practices and Pitfalls

By Daniel Ryan

DevChatt 2011

CSS3 Modules Available Today

Advanced Selectors

Advanced Selectors

Positional Selectors Demo

Multiple Classes Demo

Attribute Selectors Demo

Psuedo Selectors Demo

Form Input Selectors Demo


Properties Covered

New Color Values

In addition to the older keyword and hex colors, we now have:

HSL in Action

Backgrounds & Borders

New Border Properties

New Background Properties

Multi-column Layouts

New Properties Demo


Only -width, -count, -gap, and -rule are properly supported at this time. Items are often balanced incorrectly.

Media Queries

Two Ways to Implement

  1. Inline: @media print { … }
  2. Separate Files: <link href="print.css" rel="stylesheet" media="print">

CSS Transitions

This presentation is built solely using CSS transitions. Modernizr provides feature-detection for progressive enhancement.

.js section { display: none; }

.targetselector section, .js section { position: absolute; top: 0; right: 0; bottom: auto; left: 0; z-index: 1; min-height: 100%; min-width: 320px; }

.targetselector section { display: block; }

.opacity section { opacity: 0; }

.no-opacity section { display: none; }

.csstransitions section { transition: opacity 1s linear, z-index 1s; }

.targetselector section:target, .js section.target { opacity: 1; display: block; z-index: 2; }

section footer { position: absolute; top: auto; right: 0; bottom: 0; left: 0; padding: 1.15em; background: #333; text-align: center; }

.csstransitions.csstransforms3d.targetselector section footer { transform: translateY(4em); transform-style: preserve3d; transition: transform 1s; }

.csstransitions.csstransforms3d.targetselector section:target footer { transform: translateY(0); }

Best Practices

CSS Animations

Highlighting an Element

@keyframes highlight {
    0% {
        background: transparent;
    50% {
        background: #ff8;
    100% {
        background: transparent;

CSS Transforms

Transform Functions * denotes 3D transform

CSS Transforms (continued)

Best Practices


In Conclusion

Further Reading

Demos to Make Your <head> Spin

Automate the Vendor Prefixes

Get in Touch

If you friend me on Facebook, I might say yes. If you add me on LinkedIn, I will laugh. A lot.