Slide 1

Slide 1 text

MEANINGFUL CSS FOR A HUMANE WEB BY ERIC A. MEYER Tuesday, April 24, 12

Slide 2

Slide 2 text

ERIC A. MEYER MULTIMEDIA ARTIST+DEVELOPER ODDBIRD | COMPASS | SUSY eric.andmeyer.com | oddbird.net 108625 eriiicam ericam Tuesday, April 24, 12

Slide 3

Slide 3 text

INSPIRED BY NATALIE DOWNE’S 2008 CSS SYSTEMS http://www.slideshare.net/nataliedowne/css-systems-presentation Tuesday, April 24, 12

Slide 4

Slide 4 text

DEFINE THE PROBLEM. EMBRACE THE MEDIUM: Write meaningful code. [sass] Join the community. [compass] Design for differences. [susy] DEVELOP YOUR SYSTEM. Tuesday, April 24, 12

Slide 5

Slide 5 text

DEFINE THE PROBLEM. Tuesday, April 24, 12

Slide 6

Slide 6 text

Work as a team. Write robust + versatile code. On tight deadlines. Hand it off to other developers. Maintain it over several years. Tuesday, April 24, 12

Slide 7

Slide 7 text

DO IT ALL AGAIN. Tuesday, April 24, 12

Slide 8

Slide 8 text

YOU NEED A SYSTEM. Tuesday, April 24, 12

Slide 9

Slide 9 text

Shared vocabulary, patterns, and code. Overall structure + Individual components. Consistent across projects. Customized for each. Tuesday, April 24, 12

Slide 10

Slide 10 text

OOCSS [Nicole Sullivan | http://oocss.org/] Bootstrap [Twitter | http://twitter.github.com/bootstrap/] SMACSS [Jonathan Snook : http://smacss.com/] HTML5 Boilerplate [Paul Irish + Divya Manian | http://html5boilerplate.com/] ... Tuesday, April 24, 12

Slide 11

Slide 11 text

Start with guiding principles. Consider the process. Notice the patterns. Define abstracted modules. Tuesday, April 24, 12

Slide 12

Slide 12 text

DEFINE, DEVELOP, MAINTAIN, AND COMMUNICATE. Tuesday, April 24, 12

Slide 13

Slide 13 text

DEFINE THE PROBLEM. EMBRACE THE MEDIUM: Write meaningful code. [sass] Join the community. [compass] Design for differences. [susy] DEVELOP YOUR SYSTEM. Tuesday, April 24, 12

Slide 14

Slide 14 text

EMBRACE THE MEDIUM. Tuesday, April 24, 12

Slide 15

Slide 15 text

The World Wide Web. HyperText Markup Language. Cascading Style Sheets. Tuesday, April 24, 12

Slide 16

Slide 16 text

W3C One web. Web for all. Web on everything. Tuesday, April 24, 12

Slide 17

Slide 17 text

THERE IS NO NORMAL. Design for the differences. Tuesday, April 24, 12

Slide 18

Slide 18 text

STANDARDS. CONTENT CREATORS + WEB TECHNOLOGY DEVELOPERS + BROWSER COMPANIES. Tuesday, April 24, 12

Slide 19

Slide 19 text

WE’RE BUILDING IT TOGETHER. Join the community. Tuesday, April 24, 12

Slide 20

Slide 20 text

HTML HyperText Markup Language Tuesday, April 24, 12

Slide 21

Slide 21 text

A WEB OF META-DATA. Write meaningful code. Tuesday, April 24, 12

Slide 22

Slide 22 text

CSS Flow, Inheritance, Cascade. Tuesday, April 24, 12

Slide 23

Slide 23 text

ABSTRACTED LAYERS. Content + tags + outline + taxonomy + style. Tuesday, April 24, 12

Slide 24

Slide 24 text

DEFINE THE PROBLEM. EMBRACE THE MEDIUM: Write meaningful code. [sass] Join the community. [compass] Design for differences. [susy] DEVELOP YOUR SYSTEM. Tuesday, April 24, 12

Slide 25

Slide 25 text

WRITE MEANINGFUL CODE. Tuesday, April 24, 12

Slide 26

Slide 26 text

CSS IS SIMPLE. Selectors { Properties: Values; } + Cascade Tuesday, April 24, 12

Slide 27

Slide 27 text

CSS IS SIMPLY CRAZY. 33 NEW SELECTORS, 120+ NEW PROPERTIES, 3 NEW @-RULES, ENHANCED MEDIA QUERIES, VENDOR PREFIXES, BROWSER DIFFERENCES, LEGACY HACKS, NO LAYOUT MODULE... Tuesday, April 24, 12

Slide 28

Slide 28 text

HTTP://WWW.FLICKR.COM/PHOTOS/MIKEPMILLER/5673913884/ Tuesday, April 24, 12

Slide 29

Slide 29 text

Adding any form of macros or additional scopes and indirections, including symbolic constants... changes CSS in ways that make it unsuitable for its intended audience. —BERT BOSS, JUNE 2008 HTTP://WWW.W3.ORG/PEOPLE/BOS/CSS-VARIABLES Tuesday, April 24, 12

Slide 30

Slide 30 text

FFD8 FFE0 0010 4A46 4946 0001 0100 0001 0001 0000 FFFE 003B 4352 4541 544F 523A 2067 642D 6A70 6567 2076 312E 3020 2875 7369 6E67 2049 4A47 204A 5045 4720 7636 3229 2C20 7175 616C 6974 7920 3D20 3835 0AFF DB00 4300 0503 0404 0403 0504 0404 0505 0506 070C 0807 0707 070F 0B0B 090C 110F 1212 110F 1111 1316 1C17 1314 1A15 1111 1821 181A 1D1D 1F1F 1F13 1722 2422 1E24 1C1E 1F1E FFDB 0043 0105 0505 0706 070E 0808 0E1E 1411 141E 1E1E 1E1E 1E1E 1E1E 1E1E 1E1E 1E1E 1E1E 1E1E 1E1E 1E1E 1E1E 1E1E 1E1E 1E1E 1E1E 1E1E 1E1E 1E1E 1E1E 1E1E 1E1E 1E1E 1E1E 1EFF C000 1108 011F 0198 0301 2200 0211 0103 1101 FFC4 001F 0000 0105 0101 0101 0101 0000 0000 0000 0000 0102 0304 0506 0708 090A 0BFF C400 B510 0002 0103 0302 0403 0505 0404 0000 017D 0102 0300 0411 0512 2131 4106 1351 6107 2271 1432 8191 A108 2342 B1C1 1552 D1F0 2433 6272 8209 SIMPLE != HUMANE. .col2of6 { float: left; display: inline; width: 31.707%; margin-right: 2.439%; } /* where is col2of6? */ /* why do we float it? */ /* what? */ /* where’s that % from? */ /* another one? */ Tuesday, April 24, 12

Slide 31

Slide 31 text

MEANINGFUL == HUMANE. .col2of6 { float: left; display: inline; width: 31.707%; margin-right: 2.439%; } .article { @include columns(2); } HTTP://WWW.FLICKR.COM/PHOTOS/NICSUZOR/2554668884/ Tuesday, April 24, 12

Slide 32

Slide 32 text

THE MEANING PROBLEM: Repetition is hard to maintain. .meaning { padding: 1.5em; background: #d33682; color: #080205; } .meaning > h3 { margin: -1.5em; margin-bottom: 1.5em; padding: 1.5em; background: rgba(8, 2, 5, 0.5); color: #d33682; } Tuesday, April 24, 12

Slide 33

Slide 33 text

THE MEANING PROBLEM: Repetition is hard to maintain. Relationships are hidden. .meaning { padding: 1.5em; background: #d33682; color: #080205; } .meaning > h3 { margin: -1.5em; margin-bottom: 1.5em; padding: 1.5em; background: rgba(8, 2, 5, 0.5); color: #d33682; } Tuesday, April 24, 12

Slide 34

Slide 34 text

THE MEANING PROBLEM: Repetition is hard to maintain. Relationships are hidden. Reasons are unclear. .meaning { padding: 1.5em; background: #d33682; color: #080205; } .meaning > h3 { margin: -1.5em; margin-bottom: 1.5em; padding: 1.5em; background: rgba(8, 2, 5, 0.5); color: #d33682; } Tuesday, April 24, 12

Slide 35

Slide 35 text

Dear W3C, We rely on advanced text editors, calculators, color pickers and widgets to make writing CSS bearable. Throw us a frickin' bone! —DUŠKO ANGIREVIĆ [@DYSKO], FEB 2012 HTTPS://TWITTER.COM/#!/DYSKO/STATUSES/173037423520002048 Tuesday, April 24, 12

Slide 36

Slide 36 text

SHOW YOUR WORK. Tuesday, April 24, 12

Slide 37

Slide 37 text

CSS + Meaningful Abstraction HTTP://SASS-LANG.COM/ HAMPTON CATLIN + NATHAN WEIZENBAUM + CHRIS EPPSTEIN SASS Tuesday, April 24, 12

Slide 38

Slide 38 text

.cat { background: url(‘cat.png’); color: #fdf6e3; } .CSS Tuesday, April 24, 12

Slide 39

Slide 39 text

.SCSS .cat { background: url(‘cat.png’); color: #fdf6e3; } Tuesday, April 24, 12

Slide 40

Slide 40 text

CATCH CSS ERRORS 20 .cat { 21 background: url(‘cat.png’) 22 color: #fdf6e3; 23 } /* Syntax error: Invalid CSS after " color": expected ";", was ": #fdf6e3;" on line 22 of screen.scss */ Tuesday, April 24, 12

Slide 41

Slide 41 text

/* css -------------------- */ .nesting p { margin: .75em; } .nesting > h3 { color: #d33682; } .nesting:target { color: #fff; } .no-rgba .nesting { color: #000; } /* scss ------------------- */ .nesting { p { margin: .75em; } > h3 { color: #d33682; } &:target { color: #fff; } .no-rgba & { color: #000; } } MEANINGFUL SELECTORS Nesting, parent selector, and @extend. .demo { padding: 1.5em; } .meaning { @extend .demo; } .article { @extend .demo; } .demo, .meaning, .article { padding: 1.5em; } Tuesday, April 24, 12

Slide 42

Slide 42 text

/* css -------------------- */ .meaning { padding: 1.5em; } @media (min-width: 30em) { .meaning { padding: 0.5em; } } /* scss ------------------- */ .meaning { padding: 1.5em; @media (min-width: 30em) { padding: 0.5em; } } MEANINGFUL @MEDIA Bubbling preserves context, avoids repetition. Tuesday, April 24, 12

Slide 43

Slide 43 text

MEANINGFUL PROPERTIES Mixins. /* css ---------------------- */ .meaning { -webkit-border-radius: 0.5em; -moz-border-radius: 0.5em; -ms-border-radius: 0.5em; -o-border-radius: 0.5em; border-radius: 0.5em; } /* scss --------------------- */ .meaning { @include border-radius(.5em); } Tuesday, April 24, 12

Slide 44

Slide 44 text

/* css -------------------- */ .meaning { padding: .75em; background: #d33682; color: #080205; } .meaning > h3 { margin: -.75em; margin-bottom: .75em; padding: .75em; background: rgba(8,2,5,0.5); color: #d33682; } /* scss ------------------- */ $rhythm : 1.5em; $padding : $rhythm / 2; $bg : #d33682; $text : darken($bg,50); .meaning { padding: $padding; background: $bg; color: $text; > h3 { margin: - $padding; margin-bottom: $padding; padding: $padding; background: rgba($text,.5); color: $bg; } } MEANINGFUL VALUES Variables, math, logic, and functions. Tuesday, April 24, 12

Slide 45

Slide 45 text

/* _reset.scss -------- */ .reset { ... } /* _layout.scss ------- */ .layout { ... } /* _module.scss ------- */ .module { ... } /* screen.scss -------- */ @import “reset”; @import “layout”; @import “module”; MEANINGFUL ORGANIZATION Importing partials. Tuesday, April 24, 12

Slide 46

Slide 46 text

CSS VARIABLES MODULE LEVEL 1. W3C Working Draft 10 April 2012. Thank you, Tab Atkins! HTTP://WWW.W3.ORG/TR/2012/WD-CSS-VARIABLES-20120410/ Tuesday, April 24, 12

Slide 47

Slide 47 text

DEFINE THE PROBLEM. EMBRACE THE MEDIUM: Write meaningful code. [sass] Join the community. [compass] Design for differences. [susy] DEVELOP YOUR SYSTEM. Tuesday, April 24, 12

Slide 48

Slide 48 text

JOIN THE COMMUNITY. Tuesday, April 24, 12

Slide 49

Slide 49 text

Style Authoring Framework COMPASS HTTP://COMPASS-STYLE.ORG CHRIS EPPSTEIN + BRANDON MATHIS + ERIC MEYER + SCOTT DAVIS + NICO HAGENBURGER + ANTHONY SHORT Tuesday, April 24, 12

Slide 50

Slide 50 text

BUILD, SHARE, AND IMPORT. Tools by and for web designers. Tuesday, April 24, 12

Slide 51

Slide 51 text

COMPASS IS PROJECT AWARE Let Compass handle your assets. # config.rb -------------------/ http_path = "/" css_dir = "stylesheets" sass_dir = "sass" images_dir = "images" fonts_dir = "fonts" javascripts_dir = "js" output_style = :compact relative_assets = true line_comments = false /* scss --------------------- */ a[href*='github'] { display: block; background: image-url('github.png') no-repeat left; min-height: image-height('github.png'); padding-left: image-width('github.png') + 6px; } /* css ---------------------------------------------------------- */ a[href*='github'] { display: block; background: url('../images/github.png?1334968268') no-repeat left; min-height: 24px; padding-left: 30px;} Tuesday, April 24, 12

Slide 52

Slide 52 text

SPRITES THAT DON’T SUCK Let Compass handle your assets. File Structure ----------------/ images/ social/ dribbble.png github.png twitter.png /* scss ----------------------*/ @import "social/*.png"; @include all-social-sprites; /* css ---------------------- */ .social-sprite, .social- dribbble, .social- github, .social-twitter { background: url('../images/ social-s9c30a47a32.png') no-repeat; } .social-dribbble { background-position: 0 0; } .social-github { background-position: 0 -24px; } .social-twitter { background-position: 0 -72px; } Tuesday, April 24, 12

Slide 53

Slide 53 text

CSS3. Animations, Appearance, Background Clip, Background Origin, Background Size, Border Radius, Box Shadow, Box Sizing, CSS3 Pie, Columns, Font Face, Images, Inline Block, Opacity, Shared Utilities, Text Shadow, Transform, Transition, and User Interface. Helpers. Color functions, math, browser-support, and asset handling. Layout. Grid Background, Sticky Footer, and Stretching. Reset [Eric Meyer]. Typography. Links, Lists, Text, and Vertical Rhythm. Utilities. Color, General, Print, Sprites, and Tables. Plugins... Tuesday, April 24, 12

Slide 54

Slide 54 text

OOCSS » Several. Bootstrap » Several. SMACSS » Just Do It. HTML5 Boilerplate » Several. CSS Systems » Susy. ... » Build Your Own! Tuesday, April 24, 12

Slide 55

Slide 55 text

gem install compass Tuesday, April 24, 12

Slide 56

Slide 56 text

DEFINE THE PROBLEM. EMBRACE THE MEDIUM: Write meaningful code. [sass] Join the community. [compass] Design for differences. [susy] DEVELOP YOUR SYSTEM. Tuesday, April 24, 12

Slide 57

Slide 57 text

DESIGN FOR DIFFERENCES. Tuesday, April 24, 12

Slide 58

Slide 58 text

The control which designers know in the print medium, and often desire in the web medium, is simply a function of the limitation of the printed page... We must “accept the ebb and flow of things.” —JOHN ALLSOPP, APRIL 2000 HTTP://WWW.ALISTAPART.COM/ARTICLES/DAO/ Tuesday, April 24, 12

Slide 59

Slide 59 text

THE WEB IS RESPONSIVE. How are you going to mange it? Tuesday, April 24, 12

Slide 60

Slide 60 text

WE NEED RESPONSIVE TOOLS. When all you have are classes and IDs... Tuesday, April 24, 12

Slide 61

Slide 61 text

A RESPONSIVE PROCESS. Start with why. Work out from there. Tuesday, April 24, 12

Slide 62

Slide 62 text

1) ORGANIZED CONTENT. Static templates, markdown, and URLs. Tuesday, April 24, 12

Slide 63

Slide 63 text

2) MEANINGFUL MARKUP. Structure, microformats, WAI-ARIA. Tuesday, April 24, 12

Slide 64

Slide 64 text

3) INTERACTIVE WIREFRAMES. Mobile first, layout only, zen mind. Tuesday, April 24, 12

Slide 65

Slide 65 text

FLUID CENTER, CANDY SHELL. A fluid site can become anything. Tuesday, April 24, 12

Slide 66

Slide 66 text

width: 100%; width: 750px; width: 50em; Tuesday, April 24, 12

Slide 67

Slide 67 text

/* ------------------------------------------------------------- Span 6 columns of a 10-column grid... */ article { float: left; /* establish a column */ display: inline; /* fix double-margin bug */ width: 56.863%; /* (((6*4em)+((6-1)*1em))/51em)*100% */ margin-right: 1.961%; /* (1em/51em)*100% */ } Tuesday, April 24, 12

Slide 68

Slide 68 text

SUSY Responsive grids without math HTTP://SUSY.ODDBIRD.NET/ ERIC MEYER (ME) Tuesday, April 24, 12

Slide 69

Slide 69 text

/* ------------------------------------------------------------- Span 6 columns of a 10-column grid... */ article { @include columns(6); } Tuesday, April 24, 12

Slide 70

Slide 70 text

/* A Simple Susy Grid --------------------------------------- */ $total-cols : 10; .page { @include container; } header, footer { @include full; } nav { @include columns(4); @include alpha; } article { @include columns(6); @include omega; } Tuesday, April 24, 12

Slide 71

Slide 71 text

/* Susy 1.0 Coming Soon ------------------------------------- */ .page { @include container(4,10); } header, footer { @include at-breakpoint(10) { @include full; }; } @include at-breakpoint(10) { nav { @include columns(4 alpha); } article { @include columns(6 omega); } }; Tuesday, April 24, 12

Slide 72

Slide 72 text

DON’T FIGHT THE CASCADE. Organize CSS to avoid conflict. Tuesday, April 24, 12

Slide 73

Slide 73 text

A) ESTABLISH A BASE. Sass settings and imports. No output. Tuesday, April 24, 12

Slide 74

Slide 74 text

B) GENERAL OVERVIEW. Reset, normalize tag defaults, define helpers. Tuesday, April 24, 12

Slide 75

Slide 75 text

C) THE LAYOUT STRUCTURE. Establish grid structures with Susy. Tuesday, April 24, 12

Slide 76

Slide 76 text

D) NAMED MODULES. Class types by effect, ID’s by component. Tuesday, April 24, 12

Slide 77

Slide 77 text

1. Components over pages. 2. Types over instances. 3. Classes over IDs. Tuesday, April 24, 12

Slide 78

Slide 78 text

E) OVERRIDES BY SECTION. A last resort, for the exceptions. Tuesday, April 24, 12

Slide 79

Slide 79 text

File Structure --------------/ base/ settings/ _grid.scss _colors.scss _fonts.scss extensions/ _lightboxes.scss general/ _reset.scss _defaults.scss _helpers.scss layout/ _banner.scss _nav.scss _contentinfo.scss modules/ effects/ _dropdown.scss components/ _news.scss overrides/ _admin.scss _home.scss The Cascade -----------------/ A) Base Settings Grids Colors Fonts Extensions Lightboxes B) General Reset Defaults Helpers C) Layout Banner Nav Content-info D) Modules Effects Dropdown Components News E) Overrides Admin Home Tuesday, April 24, 12

Slide 80

Slide 80 text

DOCUMENT AS YOU GO. Write style guides with KSS to @extend later. HTTP://WARPSPIRE.COM/POSTS/KSS/ Tuesday, April 24, 12

Slide 81

Slide 81 text

4) DESIGN ELEMENTS. From modules out, from abstractions in. Tuesday, April 24, 12

Slide 82

Slide 82 text

5) BROWSER CLEANUP. Don’t be surprised when you get here. Tuesday, April 24, 12

Slide 83

Slide 83 text

FEATURE SUPPORT. Modernizr, with fallback code in context. Tuesday, April 24, 12

Slide 84

Slide 84 text

/* scss -------------------------------------------------------- */ article { @include box-sizing(border-box); width: 45%; padding: 2%; .no-boxsizing & { width: 41%; padding: 2%; } } Tuesday, April 24, 12

Slide 85

Slide 85 text

CONDITIONAL COMMENTS. With fallback code in context. Tuesday, April 24, 12

Slide 86

Slide 86 text

/* scss -------------------------------------------------------- */ .container { width: 20em; @media (min-width:50em) { width: 50em; } .lt-ie9 & { width: 50em; } } Tuesday, April 24, 12

Slide 87

Slide 87 text

DEFINE THE PROBLEM. EMBRACE THE MEDIUM: Write meaningful code. [sass] Join the community. [compass] Design for differences. [susy] DEVELOP YOUR SYSTEM. Tuesday, April 24, 12

Slide 88

Slide 88 text

BUILD YOUR SYSTEM. Tuesday, April 24, 12

Slide 89

Slide 89 text

Shared vocabulary, patterns, and code. Overall structure + Individual components. Consistent across projects. Customized for each. Tuesday, April 24, 12

Slide 90

Slide 90 text

Start with guiding principles. Consider the process. Notice the patterns. Define abstracted modules. Tuesday, April 24, 12

Slide 91

Slide 91 text

EMBRACE THE MEDIUM: Write meaningful code. [sass] Join the community. [compass] Design for differences. [susy] Tuesday, April 24, 12

Slide 92

Slide 92 text

DEFINE, DEVELOP, MAINTAIN, AND COMMUNICATE. Tuesday, April 24, 12

Slide 93

Slide 93 text

THANK YOU! Tuesday, April 24, 12

Slide 94

Slide 94 text

ERIC A. MEYER MULTIMEDIA ARTIST+DEVELOPER ODDBIRD | COMPASS | SUSY eric.andmeyer.com | oddbird.net 108625 eriiicam ericam Tuesday, April 24, 12