Slide 1

Slide 1 text

State-based design

Slide 2

Slide 2 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 3

Slide 3 text

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

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

CSS is easy.

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

li { }

Slide 11

Slide 11 text

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

Slide 12

Slide 12 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 13

Slide 13 text

What does it mean?

Slide 14

Slide 14 text

Shift your thinking

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

Think Modularly.

Slide 17

Slide 17 text

Think Modularly.

Slide 18

Slide 18 text

Scalable and Modular Architecture for CSS

Slide 19

Slide 19 text

What is SMACSS?

Slide 20

Slide 20 text

Have your CSS... Do one thing and one thing only

Slide 21

Slide 21 text

Your code should... Be clear regardless of context

Slide 22

Slide 22 text

Categorization Naming Convention

Slide 23

Slide 23 text

Categorization

Slide 24

Slide 24 text

Base

Slide 25

Slide 25 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 26

Slide 26 text

Layout

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

Sidebar Content Header

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

Module

Slide 33

Slide 33 text

Customized List Button Tabs

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

Sub-modules

Slide 42

Slide 42 text

Large Search Dark Small

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

Theme

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

State?

Slide 50

Slide 50 text

State-based Design • Class-based states • Attribute-based states • Pseudo-class states • Media query states

Slide 51

Slide 51 text

Class-based State

Slide 52

Slide 52 text

Active State Default State Disabled State Default State

Slide 53

Slide 53 text

.is-btn-active { box-shadow: inset 3px 3px 5px #333; } .is-btn-disabled { opacity: .5; pointer-events: none; }

Slide 54

Slide 54 text

/* general class-based state */ .is-hidden { }

Slide 55

Slide 55 text

$('.btn').on('mousedown', function(){ $(this).addClass('is-btn-pressed'); }); $('.btn').on('mouseup', function(){ $(this).removeClass('is-btn-pressed'); });

Slide 56

Slide 56 text

Attribute Selector State

Slide 57

Slide 57 text

.btn[data-state=default] { color: #333; } .btn[data-state=pressed] { color: #000; } .btn[data-state=disabled] { opacity: .5; pointer-events: none; } Disabled

Slide 58

Slide 58 text

// bind a click handler to each button $(".btn").on("click", function(){ // change the state to pressed $(this).attr('data-state', 'pressed'); });

Slide 59

Slide 59 text

Pseudo-class State

Slide 60

Slide 60 text

/* Pseudo-class state */ .callout:hover { } .callout:focus { }

Slide 61

Slide 61 text

:hover :focus :active :checked :indeterminate :valid :invalid :in-range :out-of-range

Slide 62

Slide 62 text

Media Query State

Slide 63

Slide 63 text

@media screen and (max-width: 400px) { .layout-content { float: none; } }

Slide 64

Slide 64 text

/* default state for nav items */ .nav > li { float: none; } /* alternate state for nav items on larger screens */ @media screen and (min-width: 400px) { .nav > li { float: left; } }

Slide 65

Slide 65 text

/* default layout */ .l-content { float: left; width: 75%; } .l-sidebar { float: right; width: 25%; } /* alternate state for layout on small screens */ @media screen and (max-width: 400px) { .l-content, .l-sidebar { float: none; width: auto; } }

Slide 66

Slide 66 text

Examples

Slide 67

Slide 67 text

No content

Slide 68

Slide 68 text

No content

Slide 69

Slide 69 text

No content

Slide 70

Slide 70 text

http://icefox.net/anigma/

Slide 71

Slide 71 text

http://my-html-codes.com/HTML5_tutorials/Dino_pairs2/index.html

Slide 72

Slide 72 text

Slide 73

Slide 73 text

.input-option { display: none; } /* Pseudo-class state */ input:checked ~ .input-option { display: block; }

Slide 74

Slide 74 text

Other?
Please specify: label>

Slide 75

Slide 75 text

Sprite Animations

Slide 76

Slide 76 text

#sprite { width:64px; height:64px; background:url(sprite.png) 0 0; }

Slide 77

Slide 77 text

@-webkit-keyframes walking { 0%! ! { background-position: 448px 0; } }

Slide 78

Slide 78 text

.is-walking { -webkit-animation-duration:600ms; -webkit-animation-iteration-count:infinite; -webkit-animation-timing-function:steps(7,end); -webkit-animation-name:walking; -webkit-animation-fill-mode: both; } .is-walking-faster { -webkit-animation-duration:400ms; } .is-walking-backwards { -webkit-animation-direction: reverse; }

Slide 79

Slide 79 text

var el=document.getElementById('sprite')

Slide 80

Slide 80 text

el.classList.toggle('is-walking');

Slide 81

Slide 81 text

toggle('is-walking'); toggle('is-walking-faster'); toggle('is-walking-backwards');

Slide 82

Slide 82 text

CSS Panic http://snk.ms/15

Slide 83

Slide 83 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 84

Slide 84 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 85

Slide 85 text

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

Slide 86

Slide 86 text

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

Slide 87

Slide 87 text

GET SMACKED http://smacss.com/

Slide 88

Slide 88 text

No content