CSS Parallax - DotCSS 2014

13

description

Slides for my lightning talk during DotCSS 2014

Transcript of CSS Parallax - DotCSS 2014

Page 1: CSS Parallax - DotCSS 2014
Page 2: CSS Parallax - DotCSS 2014
Page 3: CSS Parallax - DotCSS 2014

CSS parallax scrollingEnhanced scrolling done right.

Page 4: CSS Parallax - DotCSS 2014

Don’t use JavaScriptRepaints are evil.

Page 5: CSS Parallax - DotCSS 2014

Scrolling is sensitiveEnhance, don’t replace.

Page 6: CSS Parallax - DotCSS 2014

Keith ClarkOne smart dude.

Page 7: CSS Parallax - DotCSS 2014

Enter the third dimensionUse CSS3 perspective.

Page 8: CSS Parallax - DotCSS 2014

<body class="parallax"> <div class="parallax-layer parallax-layer-back"> ... </div> <div class="parallax-layer parallax-layer-base"> ... </div></body>

Page 9: CSS Parallax - DotCSS 2014

.parallax { height: 100vh; perspective: 1px; overflow: hidden; overflow-y: scroll;}

.parallax-layer { position: absolute; top: 0; right: 0; bottom: 0; left: 0;}

Page 10: CSS Parallax - DotCSS 2014

.parallax-layer-base { transform: translateZ(0);}.parallax-layer-back { transform: translateZ(-1px) scale(2);}

Page 11: CSS Parallax - DotCSS 2014

Any modern browserIE does not support nesting, duh.

Page 12: CSS Parallax - DotCSS 2014

More informationkeithclark.co.uk/articles/pure-css-parallax-websites/

Page 13: CSS Parallax - DotCSS 2014

Guido Boumanhttp://github.com/guidobouman