Top Banner
WYNNNETHERLAND CSS FRAMEWORKS: KING OF ALL @media ^ meta updated for Sass 3.0
141

Big Design Conference: CSS3

Jan 27, 2015

Download

Documents

Wynn Netherland

 
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Big Design Conference: CSS3

WYNNNETHERLAND

CSS FRAMEWORKS: KING OF ALL @media^meta

updated for Sass 3.0

Page 2: Big Design Conference: CSS3

Have you heard?

CSS3 is big

Page 3: Big Design Conference: CSS3

New propertiesHot

Page 4: Big Design Conference: CSS3

border-radius

Page 5: Big Design Conference: CSS3

border-image

Page 7: Big Design Conference: CSS3

background-size

Page 8: Big Design Conference: CSS3

gradients

Page 9: Big Design Conference: CSS3

RGBA, HSL, HSLA colors

rgba (0,0,0,1) is the new black!

Page 10: Big Design Conference: CSS3

text-shadow

Page 11: Big Design Conference: CSS3

box-shadow

Page 12: Big Design Conference: CSS3

wordwrap

Page 13: Big Design Conference: CSS3

outline

Page 14: Big Design Conference: CSS3

columns

Page 15: Big Design Conference: CSS3

@font-face

Typographic freedom!

means

Page 16: Big Design Conference: CSS3

New selectorsCool

Page 17: Big Design Conference: CSS3

* E

.class #id E F

E > F E + F

E[attribute] E[attribute=value] E[attribute~=value] E[attribute|=value]

:first-child :link

:visited :lang() :before ::before :after ::after

:first-letter

::first-letter :first-line ::first-line

E[attribute^=value] E[attribute$=value] E[attribute*=value]

E ~ F :root

:last-child :only-child :nth-child()

:nth-last-child() :first-of-type :last-of-type :only-of-type :nth-of-type()

:nth-last-of-type() :empty :not() :target

:enabled :disabled :checked

CSS3 selectors (and some golden oldies)

:header

Steal this from jQuery, please

Page 18: Big Design Conference: CSS3

Some smash hits from the design blogs

Page 19: Big Design Conference: CSS3

30 tips for SemanticTM markup and classes

Page 20: Big Design Conference: CSS3

101 CSS resets

Page 21: Big Design Conference: CSS3

40 Grid layouts you must see

Page 22: Big Design Conference: CSS3

7 UP-lifting reasons to use CSS Sprites

Page 23: Big Design Conference: CSS3

Have the <TABLE>'s turned?

Page 24: Big Design Conference: CSS3

30 sites for great typography

Page 25: Big Design Conference: CSS3

RT @linkbait: Effortless drop shadows, gradients, and rounded corners

Page 26: Big Design Conference: CSS3

This is not a talk about CSS

Follow @smashingmag for your CSS tips & tricks

Page 27: Big Design Conference: CSS3

REAL stylesheet innovationI want to talk about

Page 28: Big Design Conference: CSS3

HOW we write stylesheetsI want to talk about

Page 29: Big Design Conference: CSS3

how we MAINTAIN stylesheetsI want to talk about

Page 30: Big Design Conference: CSS3

how we SIMPLIFY stylesheetsI want to talk about

Page 31: Big Design Conference: CSS3

History of radioA brief

Page 32: Big Design Conference: CSS3

In the beginning...

Page 33: Big Design Conference: CSS3

AM

Page 34: Big Design Conference: CSS3

AM = Amplitude Modulation

Page 35: Big Design Conference: CSS3

Invented in 1906

Page 36: Big Design Conference: CSS3

Dominant format until 1978

Page 37: Big Design Conference: CSS3

Still rockin' after 100 years!

Page 38: Big Design Conference: CSS3

Then came

Page 39: Big Design Conference: CSS3

FM

Page 40: Big Design Conference: CSS3

FM = Frequency Modulation

Page 41: Big Design Conference: CSS3

Does not suffersusceptibility to atmospheric and

electrical interference.

Page 42: Big Design Conference: CSS3

Patented in 1933.Approved in 1941.Standardized in 1961.World domination in 1978.Unchallenged for thirty years.

Page 43: Big Design Conference: CSS3

Until...

Page 44: Big Design Conference: CSS3

XM

Page 45: Big Design Conference: CSS3

XM = Beyond FM

Hey, it was the 90s,Xs were in!

Page 46: Big Design Conference: CSS3

Founded in 1988.Launched in 2001.Merged with Sirius in 2009.

Page 47: Big Design Conference: CSS3

Superior sound.

Page 48: Big Design Conference: CSS3

No commercials.

Page 49: Big Design Conference: CSS3

Listen to Kasem's Top 40from coast to coast.

Page 50: Big Design Conference: CSS3

What the heck does this have to do with stylesheets, anyway?

Page 51: Big Design Conference: CSS3

I see some parallels.

Page 52: Big Design Conference: CSS3

History of web presentationA brief

Page 53: Big Design Conference: CSS3

In the beginning...

Page 54: Big Design Conference: CSS3

HTML

Page 55: Big Design Conference: CSS3

HTML + <TABLE>for layout

Page 56: Big Design Conference: CSS3

Invented in 1989

Page 57: Big Design Conference: CSS3

<TABLE> added in 1997

Page 58: Big Design Conference: CSS3

Still rockin' after 20 years!

Page 59: Big Design Conference: CSS3

Then came

Page 60: Big Design Conference: CSS3

HTML + CSS

Page 61: Big Design Conference: CSS3

HTML + CSS = Content + Presentation

Page 62: Big Design Conference: CSS3

CSS 1 published in 1996.

Page 63: Big Design Conference: CSS3

No more <FONT> tags.

Page 64: Big Design Conference: CSS3

font styling, color, borders & more!

Page 65: Big Design Conference: CSS3

CSS 2 published in 1998.

Page 66: Big Design Conference: CSS3

Improved selectors

Page 67: Big Design Conference: CSS3

* E

.class #id E F

E > F E + F

E[attribute] E[attribute=value] E[attribute|=value]

:first-child :link

:visited :lang() :before ::before :after ::after

:first-letter :first-line

CSS2 selectors

Page 68: Big Design Conference: CSS3

... and even more stuff no browsers supported until years later.

Page 69: Big Design Conference: CSS3

Which brings us back to...

Page 70: Big Design Conference: CSS3

CSS 3 published in 20??

Page 71: Big Design Conference: CSS3

Web 2.0 brought new demands

Page 72: Big Design Conference: CSS3

Round corners

Page 73: Big Design Conference: CSS3

Drop shadows

Page 74: Big Design Conference: CSS3

Gradients

Page 75: Big Design Conference: CSS3

But we already covered that.

Page 76: Big Design Conference: CSS3

That's the 75 slide introductionTitles are the new bullets.

Page 77: Big Design Conference: CSS3

14 years of CSS has basically given us

Page 78: Big Design Conference: CSS3

more selectors + more properties

Page 79: Big Design Conference: CSS3

Until now...

Page 80: Big Design Conference: CSS3

Metaframeworks =high fidelity stylesheets

Page 81: Big Design Conference: CSS3

Metaframeworks output CSS.

Page 82: Big Design Conference: CSS3

Nested rules

Page 83: Big Design Conference: CSS3

table.users tr td {background: #111}

table.users tr td a {color: #333}

Nested rules - selectors

Page 84: Big Design Conference: CSS3

table.users { tr { td { background: #d1d1d; a { color: #111; } } }}

Nested rules - selectors

Page 85: Big Design Conference: CSS3

table.users { tr { td { color: #111; &.alt { color: #333; } &:hover { color: #666; } } }}

Nested rules - selectors

Page 86: Big Design Conference: CSS3

.users { font: { size: 1.2em; style: italics; weight: bold; }}

Nested rules - properties

Page 87: Big Design Conference: CSS3

Syntax options

Page 88: Big Design Conference: CSS3

table.users { tr { td { background: #d1d1d; a { color: #111; } } }}

Syntax options - SCSS Sassy CSS!

Page 89: Big Design Conference: CSS3

table.users tr td background: #d1d1d a color: #111

Syntax options - Indented I ♥ whitespace

Page 90: Big Design Conference: CSS3

Variables

Page 91: Big Design Conference: CSS3

.user { background: #333; border-size: 2px;}

.owner { background: #333; border-size: 2px;}

.admin { background: #666; border-size: 4px;}

Variables

Page 92: Big Design Conference: CSS3

$gray: #333;$default_border: 2px;

.user { background: $gray; border-size: $default_border;}

.owner { background: $gray; border-size: $default_border;}

.admin { background: $gray + #333; border-size: $default_border + 2px;}

Variables

Even math!and color mixing!

Page 93: Big Design Conference: CSS3

Mixins

Page 94: Big Design Conference: CSS3

.avatar { padding: 2px; border: solid 1px #ddd; position: absolute; top: 5px; left: 5px;}

p img { padding: 2px; border: solid 1px #ddd;}

Mixins

Page 95: Big Design Conference: CSS3

@mixin frame($padding_width: 2px, $border_color: #ddd) { padding: $padding_width; border: { width: 1px; style: solid; color $border_color; }}.avatar { @include frame; position: absolute; top: 5px; left: 5px;}p img { @include frame(1px, #ccc);}

Mixins

defines the mixin

mixes in the rules

Page 96: Big Design Conference: CSS3

Extend

Page 97: Big Design Conference: CSS3

.flash { padding: 5px; border-width: 1px; font-weight: bold;}.error { color: #8a1f11; background: #fbe3e4;}.notice { color: #514721; background: #fff6bf;}

Mixins

Page 98: Big Design Conference: CSS3

.flash { padding: 5px; border-width: 1px; font-weight: bold;}

.error { @extend .flash; color: #8a1f11; background: #fbe3e4;}

.notice { @extend .flash; color: #514721; background: #fff6bf;}

Mixins

Page 99: Big Design Conference: CSS3

.flash,

.error,

.notice { padding: 5px; border-width: 1px; font-weight: bold; }

.error { color: #8a1f11; background: #fbe3e4; }

.notice { color: #514721; background: #fff6bf; }

Mixins

now we can use a single class in our markup

Page 100: Big Design Conference: CSS3

Imports

Page 101: Big Design Conference: CSS3

@import url(/css/reset.css)@import url(/css/typography.css)@import url(/css/layout.css)

Imports

parent + 3 @imports = 4 http requests

Page 102: Big Design Conference: CSS3

@import "reset.scss" # _reset.scss@import "typography" # _typography.scss@import "layout.css" # url(layout.css)

Imports

Included at compile time - just one http request

Page 103: Big Design Conference: CSS3

Imports + Mixins

Now it gets fun!

Page 104: Big Design Conference: CSS3

@import "compass/css3";

.callout { @include border-radius(5px); @include linear-gradient("left top", "left bottom", #fff, #ddd);}

.callout { -moz-border-radius: 5px; -webkit-border-radius: 5px; -border-radius: 5px; background-image: -moz-linear-gradient(top, bottom, from(#fff), to(#ddd)); background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0.00, #fff), color-stop(1.00, #ddd));}

Compass CSS3 mixins

very different syntax

Page 105: Big Design Conference: CSS3

A brief detour

Page 106: Big Design Conference: CSS3

“It’s time to abolish all vendor prefixes. They’ve become solutions for which there is no problem, and they are actively harming web standards.”

-Peter-Paul Koch aka @ppk

http://www.quirksmode.org/blog/archives/2010/03/css_vendor_pref.html

Page 107: Big Design Conference: CSS3

Ummm. Not so fast.

Page 108: Big Design Conference: CSS3

@import "compass/css3.scss";

.callout { @include border-radius(5px); @include linear-gradient("left top", "left bottom", #fff, #ddd);}

.callout { -moz-border-radius: 5px; -webkit-border-radius: 5px; -border-radius: 5px; background-image: -moz-linear-gradient(top, bottom, from(#fff), to(#ddd)); background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0.00, #fff), color-stop(1.00, #ddd));}

Compass CSS3 mixins

very different syntax

Page 109: Big Design Conference: CSS3

“Well, reactions to my proposal to abolish vendor prefixes are mixed, and I might have overshot my target here.”

-Peter-Paul Koch aka @ppk

http://www.quirksmode.org/blog/archives/2010/03/css_vendor_pref_1.html

Page 110: Big Design Conference: CSS3

Solutions?

Page 111: Big Design Conference: CSS3

beta-new-css8-property-dillyisn't that just like not having it?

...and we're back.

Page 112: Big Design Conference: CSS3

Vendor specific stylesheets

Maybe. But I'd like to retain Internet Explorer's special status unto itself

Page 113: Big Design Conference: CSS3

CSS preprocesorsHey, funny you should ask!

Page 114: Big Design Conference: CSS3

css3/border_radius.sasscss3/inline_block.sasscss3/opacity.sasscss3/text_shadow.sasscss3/box_shadow.sasscss3/columns.sasscss3/box_sizing.sasscss3/gradient.sasscss3/background_clip.sasscss3/background_origin.sasscss3/background_size.sasscss3/font_face.sasscss3/transform.sasscss3/transition.sass

Compass CSS3 mixins

Page 115: Big Design Conference: CSS3

Bring your favorite CSS Framework

Page 116: Big Design Conference: CSS3

<div id='wrapper' class="container"> <div id='content' class="span-7 prepend-1"> <div id='main' class="container"> ... </div> <div id='featured' class="span-5 last"> ... </div> </div> <div id='sidebar' class="span-3 append-1 last"> ... </div></div>

A Blueprint example

boo

Page 117: Big Design Conference: CSS3

#wrapper { @include container; #content { @include column(7); @include append(1); #featured { @include column(5, true); } } #sidebar { @include column(3, true); @include prepend(1); }}

A Blueprint example

Page 118: Big Design Conference: CSS3

Functions

Page 119: Big Design Conference: CSS3

Very. Powerful. Functions.

Page 120: Big Design Conference: CSS3

hue(#cc3) => 60degsaturation(#cc3) => 60%lightness(#cc3) => 50%

adjust-hue(#cc3, 20deg) => #9c3saturate(#cc3, 10%) => #d9d926desaturate(#cc3, 10%) => #bfbf40lighten(#cc3, 10%) => #d6d65cdarken(#cc3, 10%) => #a3a329

grayscale(#cc3) => desaturate(#cc3, 100%) = #808080complement(#cc3) => adjust-hue(#cc3, 180deg) = #33c

mix(#cc3, #00f) => #e56619mix(#cc3, #00f, 10%) => #f91405mix(#cc3, #00f, 90%) => #d1b72d

Sass 2.4 color functions

http://nex-3.com/posts/89-powerful-color-manipulation-with-sass

Page 121: Big Design Conference: CSS3

mix(rgba(51, 255, 51, 0.75), #f00) => rgba(178, 95, 19, 0.875)mix(rgba(51, 255, 51, 0.90), #f00) => rgba(163, 114, 22, 0.95)

alpha(rgba(51, 255, 51, 0.75)) => 0.75opacity(rgba(51, 255, 51, 0.75)) => 0.75

opacify(rgba(51, 255, 51, 0.75), 0.1) => rgba(51, 255, 51, 0.85)fade-in(rgba(51, 255, 51, 0.75), 0.1) => rgba(51, 255, 51, 0.85)

transparentize(rgba(51, 255, 51, 0.75), 0.1) => rgba(51, 255, 51, 0.65)fade-out(rgba(51, 255, 51, 0.75), 0.1) => rgba(51, 255, 51, 0.65)

Sass 2.4 color functions with alpha support!

http://nex-3.com/posts/89-powerful-color-manipulation-with-sass

Page 122: Big Design Conference: CSS3

Share your patterns

Page 124: Big Design Conference: CSS3

Image sprites

Page 125: Big Design Conference: CSS3

EXAMPLE 1a.twitter +sprite-img("icons-32.png", 1)a.facebook +sprite-img("icons-32png", 2)...

EXAMPLE 2a +sprite-background("icons-32.png") a.twitter +sprite-column(1) a.facebook +sprite-row(2) ...

Image sprites

Page 126: Big Design Conference: CSS3

URL helpers

Page 127: Big Design Conference: CSS3

#nav { background: image-url("nav_bg.png") repeat-x top center;}

DEVELOPMENT#nav { background: url("/images/nav_bg.png") repeat-x top center;}

PRODUCTION#nav { background: url("http://assets.example.com/images/nav_bg.png") repeat-x top center;}

URL helpers

relative paths for development,

absolute for production

Page 128: Big Design Conference: CSS3

stylesheet-url($path)

font-url($path)

image-url($path)

URL helpers

Page 129: Big Design Conference: CSS3

Who makes this syntactic sugar?

Page 130: Big Design Conference: CSS3

Sass and Compassoh yeah, and haml, too

Page 131: Big Design Conference: CSS3

hamlsass

Page 132: Big Design Conference: CSS3

hamlsass

Page 133: Big Design Conference: CSS3

$ sudo gem install haml$ sudo gem install compass --pre

CALL IT FROM THE COMMAND LINE$ sass --watch screen.scss

OR COMPASS-IZE YOUR PROJECT$ compass --rails -f blueprint

OR WATCH A FOLDER$ compass --watch

Sass and Compass

Page 134: Big Design Conference: CSS3

$ sudo gem install compass-wordpress

CRANK OUT A NEW SASS-Y WORDPRESS THEME$ compass -r compass-wordpress \ -f wordpress  -p thematic \ --sass-dir=sass --css-dir=css \ -s compressed my_awesome_theme

AUTOCOMPILE YOUR CHANGES$ compass --watch

Compass and WordPress shameless plug

Page 135: Big Design Conference: CSS3

DEMOand code spelunking

Page 136: Big Design Conference: CSS3

What's the future?

Page 137: Big Design Conference: CSS3

First, grow the category

Page 138: Big Design Conference: CSS3
Page 139: Big Design Conference: CSS3

Next, recruit some talent

Page 140: Big Design Conference: CSS3

You'll love it or hate it.