Slide 1

Slide 1 text

YOUR CSS IS A MESS

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

1 person.

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

4 designers.

Slide 7

Slide 7 text

5 developers.

Slide 8

Slide 8 text

1 team.

Slide 9

Slide 9 text

1 project.

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

30 designers.

Slide 12

Slide 12 text

5 prototypers.

Slide 13

Slide 13 text

200 engineers.

Slide 14

Slide 14 text

multiple teams.

Slide 15

Slide 15 text

multiple projects.

Slide 16

Slide 16 text

CSS is easy.

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

li { }

Slide 20

Slide 20 text

oat: left padding: 3px 50px; margin: 0;

Slide 21

Slide 21 text

.block { display:block !important; } .inline { display:inline !important; } .hide { display:none !important; } .s-none { margin:0 !important; } .s { margin:10px !important; } .ss { margin:20px !important; } .sr { margin-right:10px !important; } .p-none { padding:0 !important; } .p { padding:10px !important; } .pp { padding:20px !important; } .pt { padding-top:10px !important; } .w-auto { width:auto !important; }

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

.layout_1_2 #blogList .pageitem .statusBar {} .layout_1_2 #blogList .pageitem .statusBar .status, #blogList .pageitem .statusBar .status .status1 { } .layout_1_2 #blogList .pageitem .statusBar .status { } .layout_1_2 #blogList .pageitem .statusBar .status .status1 { } .layout_1_2 #blogList .pageitem .statusBar .status .status1 a { } .layout_1_2 #blogList .pageitem .statusBar .status .status1 .sep {}

Slide 24

Slide 24 text

.layout_1_2 #blogList .pageitem .statusBar {} .layout_1_2 #blogList .pageitem .statusBar .status, #blogList .pageitem .statusBar .status .status1 { } .layout_1_2 #blogList .pageitem .statusBar .status { } .layout_1_2 #blogList .pageitem .statusBar .status .status1 { } .layout_1_2 #blogList .pageitem .statusBar .status .status1 a { } .layout_1_2 #blogList .pageitem .statusBar .status .status1 .sep {}

Slide 25

Slide 25 text

#nav-header ul li { float: left; ... } #nav-content ul li { float: left; ... }

Slide 26

Slide 26 text

#comments .comment .meta .authorname {} #comments .comment .meta .commentnumber a {}

Slide 27

Slide 27 text

#comments .comment .meta .authorname {} #comments .comment .meta .commentnumber a {}

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

Scalable and Modular Architecture for CSS

Slide 32

Slide 32 text

SMACSS

Slide 33

Slide 33 text

3 Considerations

Slide 34

Slide 34 text

3 Categorization Naming Convention Decouple HTML/CSS

Slide 35

Slide 35 text

1 Categorization

Slide 36

Slide 36 text

Categorization • Base • Layout • Module • State • Theme

Slide 37

Slide 37 text

Base

Slide 38

Slide 38 text

html { background-color: #FFF; font-family: Arial, Helvetica, sans-serif; font-size: 14px; } body { margin: 0; padding: 0; } h1, h2, h3 { margin: 1em 0; }

Slide 39

Slide 39 text

Layout

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

Sidebar Content Header

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

Module

Slide 45

Slide 45 text

Customized List Button Tabs

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

No content

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

Sub-modules

Slide 54

Slide 54 text

Large Search Dark Small

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

No content

Slide 57

Slide 57 text

No content

Slide 58

Slide 58 text

Sub-components

Slide 59

Slide 59 text

No content

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

State

Slide 62

Slide 62 text

Active State Default State Disabled State Default State

Slide 63

Slide 63 text

Theme

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

No content

Slide 66

Slide 66 text

No content

Slide 67

Slide 67 text

Have your CSS (and HTML)... Do one thing and one thing only

Slide 68

Slide 68 text

http://snk.ms/1r The Single Responsibility Theory

Slide 69

Slide 69 text

...

Slide 70

Slide 70 text

.grid {} .col { float:left; } .col:nth-child(2n) { clear:left; } .module { display:inline-block; }

Slide 71

Slide 71 text

...

Slide 72

Slide 72 text

  • ...

Slide 73

Slide 73 text

.grid {} .grid > li { float:left; } .grid > li:nth-child(2n) { clear:left; } .module { display:inline-block; }

Slide 74

Slide 74 text

  • ...

Slide 75

Slide 75 text

  • {{item}}

Slide 76

Slide 76 text

  • ...
  • ...

    Slide 77

    Slide 77 text

    Categorization is about Isolation

    Slide 78

    Slide 78 text

    2 Naming Convention

    Slide 79

    Slide 79 text

    Naming Convention Naming convention clari es intent

    Slide 80

    Slide 80 text

    Use Class over ID Don’t use a grenade to dig a hole when a shovel will do.

    Slide 81

    Slide 81 text

    Specificity Inline ID Class (pseudo-classes and attribute selectors) Element (pseudo- elements) style="..." #article .article :hover [attr=val] a : rst-child

    Slide 82

    Slide 82 text

    Specificity Inline ID Class (pseudo-classes and attribute selectors) Element (pseudo- elements) style="..." #article .article :hover [attr=val] a : rst-child

    Slide 83

    Slide 83 text

    a { color: #039; } .subdued { color: #666; } #cancel { color: #900; } Link Link Link Link

    Slide 84

    Slide 84 text

    No content

    Slide 85

    Slide 85 text

    a { color: #039; } .subdued { color: #666 !important; } #cancel { color: #900; } Link Link Link Link

    Slide 86

    Slide 86 text

    Specificity Buster! !important

    Slide 87

    Slide 87 text

    Specificity Buster! !important

    Slide 88

    Slide 88 text

    a { color: #039; } .subdued, #cancel.subdued { color: #666; } #cancel { color: #900; } Link Link Link Link

    Slide 89

    Slide 89 text

    a { color: #039; } .subdued { color: #666; } .cancel { color: #900; } Link Link Link Link

    Slide 90

    Slide 90 text

    .btn {} .btn-large {} .btn-small {} .btn-default {} .btn-search {} .modal {} .modal-large .modal-header {} .modal-body {} .modal-footer {}

    Slide 91

    Slide 91 text

    No content

    Slide 92

    Slide 92 text

    .btn {} .is-btn-active {} .is-btn-disabled {}

    Slide 93

    Slide 93 text

    .modulename .modulename-submodule .modulename-subcomponent No hyphens Always a root node No hyphens No difference from submodule

    Slide 94

    Slide 94 text

    .module-name .module-name--submodule .module-name__subcomponent allows for hyphens Always a root node Alternatives underscores hyphens

    Slide 95

    Slide 95 text

    .moduleName .moduleName-subModule .moduleName--subComponent camelCase Alternatives double hyphen single hyphen

    Slide 96

    Slide 96 text

    Naming Convention • Pick a system that works for you and your team • Be consistent • Consider: • Root node • Sub-modules • Sub-components

    Slide 97

    Slide 97 text

    3 Decoupling CSS from HTML

    Slide 98

    Slide 98 text

    .nav { margin: 0; padding: 0; list-style: none; } .nav li { float: left; } .nav li a { display: block; padding: 5px 10px; background-color: blue; }

    Slide 99

    Slide 99 text

    Slide 100

    Slide 100 text

    Slide 101

    Slide 101 text

    .nav ul { margin: 0; padding:0; list-style:none; } .nav li li { float: none; } .nav li li a { padding: 2px; background-color: red; }

    Slide 102

    Slide 102 text

    .nav { margin: 0; padding: 0; list-style: none; } .nav > li { float: left; } .nav > li > a { display: block; padding: 5px 10px; background-color: blue; }

    Slide 103

    Slide 103 text

    .menu { margin: 0; padding: 0; list-style: none } .menu > li > a { display: block; padding: 2px; background-color: red; }

    Slide 104

    Slide 104 text

    Please. Use child selectors

    Slide 105

    Slide 105 text

    Sites I Like

    Slide 106

    Slide 106 text

    .box { border: 1px solid #333; } .box h2 { margin: 0; padding: 5px 10px; border-bottom: 1px solid #333; background-color: #CCC; } .box ul { margin: 10px; }

    Slide 107

    Slide 107 text

    Sites I Like

    About Us

    The Fancy Pants Company is all about fancy pants.

    Sponsored By

    ...

    Slide 108

    Slide 108 text

    .box { border: 1px solid #333; } .box h2 { margin: 0; padding: 5px 10px; border-bottom: 1px solid #333; background-color: #CCC; } .box ul, .box p, .box div { margin: 10px; }

    Slide 109

    Slide 109 text

    .box { border: 1px solid #333; } .box h2 { margin: 0; padding: 5px 10px; border-bottom: 1px solid #333; background-color: #CCC; } .box-body { margin: 10px; }

    Slide 110

    Slide 110 text

    Sites I Like

    About Us

    The Fancy Pants Company is all about fancy pants.

    Sponsored By

    ...

    Slide 111

    Slide 111 text

    when the HTML can’t or won’t be predictable Apply a class

    Slide 112

    Slide 112 text

    Or make the html predictable

    Slide 113

    Slide 113 text

    Sites I Like

    About Us

    The Fancy Pants Company is all about fancy pants.

    Sponsored By

    ...

    Slide 114

    Slide 114 text

    What does it mean?

    Slide 115

    Slide 115 text

    Shift your thinking

    Slide 116

    Slide 116 text

    Don’t code CSS for the page. Code it for the system.

    Slide 117

    Slide 117 text

    State-based Design

    Slide 118

    Slide 118 text

    State-based Design • A layout or module style • Sub-modules • JavaScript-driven states • Pseudo-class states • Media query states

    Slide 119

    Slide 119 text

    CSS Panic http://snk.ms/15

    Slide 120

    Slide 120 text

    .enemys { z-index:3; position:absolute; top:0px; left:0; width:49px; height:93px; display:block; -webkit-appearance: button; -moz-appearance: button; background-position:0px 0px; background-repeat:no-repeat; -webkit-animation-iteration-count:infinite cursor:pointer; opacity:0.9; border:none;

    Slide 121

    Slide 121 text

    .enemys { z-index:3; position:absolute; top:0px; left:0; width:49px; height:93px; display:block; -webkit-appearance: button; -moz-appearance: button; background-position:0px 0px; background-repeat:no-repeat; -webkit-animation-iteration-count:infinite cursor:pointer; opacity:0.9; border:none;

    Slide 122

    Slide 122 text

    .enemys:checked{ overflow:hidden; -webkit-animation-name: none; -webkit-pointer-events: none; pointer-events: none; opacity:0; }

    Slide 123

    Slide 123 text

    .enemys:checked{ overflow:hidden; -webkit-animation-name: none; -webkit-pointer-events: none; pointer-events: none; opacity:0; }

    Slide 124

    Slide 124 text

    3 Categorization Naming Convention Decouple HTML/CSS

    Slide 125

    Slide 125 text

    http://smacss.com/ Thanks!