Look ma! No images!

36
Look ma, NO IMAGES! Lennart Schoors

description

The why and how of using CSS to generate visuals.

Transcript of Look ma! No images!

Page 1: Look ma! No images!

Look ma,NO IMAGES!

Lennart Schoors

Page 2: Look ma! No images!

Me

.web designer at Massive Mediahttp://massivemedia.eu

. personal site at http://lensco.be

.@lensco

Page 3: Look ma! No images!

Somewhere last year, all the craze began...

Page 9: Look ma! No images!

Nice gimmick to show off your 1337 skillz !!1!

But there's some real value here as well...

Page 10: Look ma! No images!

Why use CSS to make visuals?

Page 11: Look ma! No images!

1. Performance

. smaller overal filesize (but not always, mind you!)

. the iOS icons example:56K (not g-zipped)

. fewer HTTP requests

Page 12: Look ma! No images!

2. Maintainability

.everything in one place

.no need to open an editor and resave a file just to tweak a color or shape

Page 13: Look ma! No images!

3. Resolution independence

. full page zooming

.blurry images vs crisp HTML + CSS

Page 14: Look ma! No images!

Examples from bricss.net

Page 15: Look ma! No images!

How to: Shapes

Page 16: Look ma! No images!

Rectangles

I assume you already know how to do this, right?

Page 17: Look ma! No images!

Circles/ellipses/rounded rects

-webkit-border-radius -moz-border-radius border-radius

Page 18: Look ma! No images!

Example: Bricss logo

Page 19: Look ma! No images!

Example: Bricss logo

Page 20: Look ma! No images!

Triangles

border-bottom: 20px solid yellow;border-left: 10px solid transparent;border-right: 10px solid transparent;

Page 21: Look ma! No images!

Triangles

border-top: 20px solid yellow;border-right: 20px solid transparent;

Beware of bad anti-aliasing!

Page 22: Look ma! No images!

Triangles: using gradients

background: -webkit-gradient(linear, 0 0, 100% 100%, color-stop(.5,transparent), color-stop(.5, yellow)),-webkit-gradient(linear, 0 100%, 100% 0, color-stop(.5,transparent), color-stop(.5, yellow)),-webkit-gradient(linear, 0 0, 100% 0, from(yellow), to(yellow));

background: -moz-linear-gradient(-45deg, transparent 50%, yellow 50%),-moz-linear-gradient(45deg, transparent 50%, yellow 50%),-moz-linear-gradient(yellow, yellow);

background-position: 0 0, 0 100%, 10px 0;

background-size: 10px 50%, 10px 50%, 100% 100%;

Better anti-aliasing, but verbose & cumbersome!

Page 23: Look ma! No images!

How to: Generating

Page 24: Look ma! No images!

HTML elements

.div, span, p, a, ... whatever suits best

. try to avoid extra/empty/unnecessary elements

Page 25: Look ma! No images!

Generated content

. :before & :after pseudo-selectors

div:after {content: "";position: absolute;/* other styles */}

Page 26: Look ma! No images!

Example: date ribbon

.date { background: #fc0; position: relative; } .date:before, .date:after { content: " "; position: absolute; border-top: 5px solid #fc0; border-left: 15px solid transparent; bottom: -5px; right: 0; } .date:after { border-left: none; border-right: 15px solid transparent; right: auto; left: 0; }

Page 27: Look ma! No images!

How to: Manipulating

Page 28: Look ma! No images!

Masks

square mask: container element with overflow: hidden

Page 29: Look ma! No images!

Transforms

. translate/translateX/translateY

. rotate

rotate(-45deg) = +

Page 30: Look ma! No images!

How to: Effects

Page 31: Look ma! No images!

CSS3 FTW

.gradients

.box-shadow

.box-reflect

. ...

Page 34: Look ma! No images!

Browser support?

Page 35: Look ma! No images!

Your good friend Internet Explorer.

.Various levels of supporttriangles: IE6, border-radius: IE9, ...

. If you only aim for IE9+ support, go nuts.

.Google dropping support for IE7 this summer.

.Do websites have to look the same in every browser?

.My motto: If it works, it works.™

Page 36: Look ma! No images!

That’s all folks!

Read on at http://lensco.be & http://bricss.net

Questions?