keep calm and let's play css3

156
@raphaelfabeni TDC 2014 KEEP CALM AND LET’S PLAY CSS3 RIGHT NOW

Upload: a2-comunicacao

Post on 30-Jun-2015

273 views

Category:

Technology


0 download

DESCRIPTION

Palestra apresentada no TDC 2014 pelo desenvolvedor Raphael Fabeni, que fala sobre a utilização de CSS3 e SASS em projetos web.

TRANSCRIPT

Page 1: Keep calm and let's play CSS3

@raphaelfabeni TDC 2014

KEEP CALM AND LET’S PLAY CSS3 RIGHT NOW

Page 2: Keep calm and let's play CSS3
Page 4: Keep calm and let's play CSS3

http://www.a2comunicacao.com.br

Page 5: Keep calm and let's play CSS3

http://bit.ly/raphael-tableless

Page 6: Keep calm and let's play CSS3

http://bit.ly/css-sp

Page 7: Keep calm and let's play CSS3

KEEP CALM...

Page 8: Keep calm and let's play CSS3

“CSS3 contains just about everything that’s included in CSS2.1 (the previous version of the

specification). It also adds new features to help developers solve a number of problems without

the need for non-semantic markup, complex scripting, or extra images.”

Page 9: Keep calm and let's play CSS3

http://bit.ly/start-using-html5-css3

Page 10: Keep calm and let's play CSS3
Page 11: Keep calm and let's play CSS3

CLIENTES

Page 12: Keep calm and let's play CSS3

Poder de convencimento

Page 13: Keep calm and let's play CSS3

diminuir o tempo de desenvolvimento

oferecer mais funcionalidades

design/ux melhores

projeto mais barato

Page 14: Keep calm and let's play CSS3

USUÁRIOS

Page 15: Keep calm and let's play CSS3

a experiência

não importa como você chegou lá

acessar informação

Page 16: Keep calm and let's play CSS3

DESENVOLVEDORES

Page 17: Keep calm and let's play CSS3

mais fios de cabelo

mais horas de game

menos restrição

Page 18: Keep calm and let's play CSS3

“Sometimes it feels that we are hiding behind the lack of cross-browser compatibility to avoid

learning new techniques that would actually dramatically improve our workflow. And that’s just wrong.”

Vitaly Friedman

Page 19: Keep calm and let's play CSS3

http://bit.ly/canvas-svg-w-time-machine

Page 20: Keep calm and let's play CSS3

Por que não mudamos?

Page 21: Keep calm and let's play CSS3

MEDO

Page 22: Keep calm and let's play CSS3

MEDO CONFORTO

Page 23: Keep calm and let's play CSS3

MEDO

DÚVIDA

CONFORTO

Page 24: Keep calm and let's play CSS3

MEDO

DÚVIDA

CONFORTO

É MUITO CEDO

Page 25: Keep calm and let's play CSS3
Page 26: Keep calm and let's play CSS3

CSS3 é fantástico!

Page 27: Keep calm and let's play CSS3

http://bit.ly/pikachu-css

Page 28: Keep calm and let's play CSS3

O dev descobrindo que o site tinha um monte de borda arredondanda e sombra...

Alguns anos atrás...

Page 29: Keep calm and let's play CSS3

Aceitar que algumas coisas não irão funcionar em

navegadores mais antigos!

Page 30: Keep calm and let's play CSS3

O usuário tem que atingir seu objetivo!

Page 31: Keep calm and let's play CSS3

PROGRESSIVE ENHANCEMENT E GRACEFUL DEGRADATION

Page 32: Keep calm and let's play CSS3

Graceful Degradation

Progressive Enhancement

Page 33: Keep calm and let's play CSS3

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod

Page 34: Keep calm and let's play CSS3

O melhor é aquele que mais se adapta a você ou seu time!

Page 35: Keep calm and let's play CSS3
Page 36: Keep calm and let's play CSS3

FLEXÍVEL

Page 37: Keep calm and let's play CSS3

FLEXÍVEL ESCALA

Page 38: Keep calm and let's play CSS3

FLEXÍVEL

LEVEZA

ESCALA

Page 39: Keep calm and let's play CSS3

FLEXÍVEL

LEVEZA

ESCALA

VELOCIDADE

Page 40: Keep calm and let's play CSS3

EXPERIMENTO

Page 41: Keep calm and let's play CSS3

EXPERIMENTO EXCESSO

Page 42: Keep calm and let's play CSS3

EXPERIMENTO

SUPORTE

EXCESSO

Page 43: Keep calm and let's play CSS3

EXPERIMENTO

SUPORTE

EXCESSO

REDUNDÂNCIA

Page 44: Keep calm and let's play CSS3

PRÉ-PROCESSADORES

Page 45: Keep calm and let's play CSS3
Page 46: Keep calm and let's play CSS3

http://bit.ly/pre-processors-miller-medeiros

Page 47: Keep calm and let's play CSS3

http://bit.ly/css-steroids

Page 48: Keep calm and let's play CSS3

http://bit.ly/pre-processadores-diego-eis

Page 49: Keep calm and let's play CSS3

“Pré processadores podem ajudar como também podem maltratar

bastante. Basta um escorregão para que seu projeto vire um inferno.”

Diego Eis

Page 50: Keep calm and let's play CSS3

“Pré-processadores são apenas ferramentas. Eles

nunca deixarão seu código ruim em um código bom.”

Lucas Mazza

Page 51: Keep calm and let's play CSS3

Aprenda CSS primeiro!

Page 52: Keep calm and let's play CSS3

Aprenda os paranauês do CSS primeiro!

De novo...

Page 53: Keep calm and let's play CSS3

MIXINS e PLACEHOLDERS

Page 54: Keep calm and let's play CSS3

http://bit.ly/mixin-placeholder

Page 55: Keep calm and let's play CSS3

@mixin center() {

display: block;

margin-left: auto;

margin-right: auto;

}

.class-one {

@include center();

}

.class-two {

@include center();

}

Mixin Placeholder

%center {

display: block;

margin-left: auto;

margin-right: auto;

}

.class-one {

@extend %center;

}

.class-two {

@extend %center;

}

Page 56: Keep calm and let's play CSS3

Mixin Placeholder

.class-one {

display: block;

margin-left: auto;

margin-right: auto;

}

.class-two {

display: block;

margin-left: auto;

margin-right: auto;

}

.class-one,

.class-two {

display: block;

margin-left: auto;

margin-right: auto;

}

Page 57: Keep calm and let's play CSS3

Mixin Placeholder

@mixin size($width, $height) {

height: $height;

width: $width;

}

.class-one {

@include size(900px, 80px);

}

.class-two {

@include size(150px, 50px);

}

%center {

width: 100px;

height: 150px;

}

.class-one {

@extend %center;

}

.class-two {

@extend %center;

}

Page 58: Keep calm and let's play CSS3

Mixin Placeholder

.class-one {

height: 80px;

width: 900px;

}

.class-two {

height: 50px;

width: 150px;

}

.class-one,

.class-two {

width: 100px;

height: 150px;

}

Page 59: Keep calm and let's play CSS3

podem mudar utilize

Mixins

Se você tem blocos de código com valores de

propriedades que...

são fixos utilize

Placeholders

Page 60: Keep calm and let's play CSS3

Let’s play...

• Background-size • Multiple-backgrounds • Opacity • Border-radius • Box-shadow

• Text-shadow • Gradient • Columns • Transform • Transition • Animation

Page 61: Keep calm and let's play CSS3

1. Background-size 2. Multiple-backgrounds 3. Opacity 4. Border-radius 5. Box-shadow

6. Text-shadow 7. Columns 8. Gradients 9. Transform 10. Transition 11. Animation

2

3

4 5

6

7

8

9

10

11 1

Page 62: Keep calm and let's play CSS3

background-size

Page 63: Keep calm and let's play CSS3

9.0 4.0 3.1 5.0

10.0 10.5

3.2 4.0

3.6 4.0

mini 5.0 2.1

2.2 7.0 10 35 30 10

Suporte

background-size

Page 64: Keep calm and let's play CSS3

Sintaxe

background-size: auto|length|cover|contain;

-webkit-background-size: value;

-moz-background-size: value;

-o-background-size: value;

background-size: value;

background-size

Prefixos

Page 65: Keep calm and let's play CSS3

@mixin background-size($value) {

-webkit-background-size: $value;

-moz-background-size: $value;

-o-background-size: $value;

background-size: $value;

}

.class { @include background-size(auto 100%); }

Mixin

background-size

.class {

-webkit-background-size: auto 100%;

-moz-background-size: auto 100%;

-o-background-size: auto 100%;

background-size: auto 100%;

}

Page 66: Keep calm and let's play CSS3

background-size

.class { @include background-size(auto 100%); }

Page 67: Keep calm and let's play CSS3

background-size

.class { @include background-size(100% auto); }

Page 68: Keep calm and let's play CSS3

multiple backgrounds

Page 69: Keep calm and let's play CSS3

9.0 4.9 3.1 10.5

3.2

3.6

mini 5.0 2.1 7.0 10 35 30 10

Suporte

multiple-backgrounds

Page 70: Keep calm and let's play CSS3

background:

url(cbf.png) right top no-repeat,

url(maracana.jpg) center center no-repeat;

Sintaxe

multiple-backgrounds

Page 71: Keep calm and let's play CSS3

opacity

Page 72: Keep calm and let's play CSS3

5.5 9.0

4.0 3.1 9.0

3.2

2.0

mini 5.0 2.1 7.0 10 35 30 10

Suporte

opacity

Page 73: Keep calm and let's play CSS3

opacity: value;

@mixin opacity($value) {

opacity: $value;

filter: alpha(opacity=($value * 100));

}

.class { @include opacity(0.5); }

Sintaxe

Mixin

opacity

Page 74: Keep calm and let's play CSS3

border-radius

Page 75: Keep calm and let's play CSS3

9.0 4.0 5.0

3.1 5.0

10.5

3.2

2.0 3.6

mini ... 2.1 7.0 11.5 35 30 10

Suporte

border-radius

Page 76: Keep calm and let's play CSS3

border-radius: value(1 – 4);

1 2

4 3

Sintaxe

border-radius

Prefixos -webkit-border-radius: value;

-moz-border-radius: value;

border-radius: value;

Page 77: Keep calm and let's play CSS3

@mixin border-radius($topL, $topR, $bottomR, $bottomL) {

-webkit-border-radius: $topL $topR $bottomR $bottomL;

-moz-border-radius: $topL $topR $bottomR $bottomL;

border-radius: $topL $topR $bottomR $bottomL;

}

.class { @include border-radius(50px, 75px, 25px, 40px); }

Mixin

border-radius

Page 78: Keep calm and let's play CSS3

@mixin border-radius($topL, $topR, $bottomR, $bottomL) {

-webkit-border-radius: $topL $topR $bottomR $bottomL;

-moz-border-radius: $topL $topR $bottomR $bottomL;

border-radius: $topL $topR $bottomR $bottomL;

}

.class { @include border-radius(50px, 75px, 25px, 40px); }

Mixin

border-radius

.class { @include border-radius(50px, 50px, 50px, 50px); }

Page 79: Keep calm and let's play CSS3

@mixin border-radius($radius) {

-webkit-border-radius: $radius;

-moz-border-radius: $radius;

border-radius: $radius;

}

.class { @include border-radius(30px 10px 10px 5px); }

.class { @include border-radius(15px); }

Mixin

border-radius

Page 80: Keep calm and let's play CSS3

box-shadow

Page 81: Keep calm and let's play CSS3

9.0 4.0 3.1 5.0

10.5

3.2 4.1

3.5

mini ... 2.1

4.0 7.0 11.5 35 30 10

Suporte

box-shadow

Page 82: Keep calm and let's play CSS3

box-shadow: horizShadow vertShadow blur spread color inset;

horizontal shadow + -

+

-

vertical shadow

spread blur

box-shadow: 1px 1px 5px 1px #000;

+ -

inset

+

-

Sintaxe

box-shadow

Page 83: Keep calm and let's play CSS3

@mixin box-shadow($values) {

-webkit-box-shadow: $values;

-moz-box-shadow: $values;

box-shadow: $values;

}

Mixin

box-shadow

-webkit-box-shadow: value;

-moz-box-shadow: value;

box-shadow: value;

Prefixos

Page 84: Keep calm and let's play CSS3

.class {

@include box-shadow(

1px 1px 10px 1px #000,

1px -5px 3px 5px #666 inset);

}

.class { @include box-shadow(1px 1px 10px 1px #000); }

.class { @include box-shadow(1px -5px 3px 5px #666 inset); }

box-shadow

Page 85: Keep calm and let's play CSS3

@mixin box-shadow($values) {

-webkit-box-shadow: $values;

-moz-box-shadow: $values;

box-shadow: $values;

}

Mixin

box-shadow

@mixin box-shadow($value1, $value2) {

-webkit-box-shadow: $value1, $value2;

-moz-box-shadow: $value1, $value2;

box-shadow: $value1, $value2;

}

Page 86: Keep calm and let's play CSS3

@mixin box-shadow($values) {

-webkit-box-shadow: $values;

-moz-box-shadow: $values;

box-shadow: $values;

}

Mixin

box-shadow

@mixin box-shadow($value1, $value2) {

-webkit-box-shadow: $value1, $value2;

-moz-box-shadow: $value1, $value2;

box-shadow: $value1, $value2;

}

@mixin box-shadow($values...) {

-webkit-box-shadow: $values;

-moz-box-shadow: $values;

box-shadow: $values;

}

Page 87: Keep calm and let's play CSS3

Mixin

box-shadow

@mixin box-shadow($values...) {

-webkit-box-shadow: $values;

-moz-box-shadow: $values;

box-shadow: $values;

}

.class {

@include box-shadow(

1px 1px 10px 1px #000,

1px -5px 3px 5px #666 inset);

}

Page 88: Keep calm and let's play CSS3

.class { @include box-shadow( 5px 5px 10px 1px #fff ); }

box-shadow

.class { @include box-shadow(0px 0px 20px 20px #247388 inset); }

Page 89: Keep calm and let's play CSS3

text-shadow

Page 90: Keep calm and let's play CSS3

10 4.0 3.1 4.0

9.6

3.2

3.5

mini 7.0 2.1 7.0

10 10 35 30 10

Suporte

text-shadow

Page 91: Keep calm and let's play CSS3

text-shadow: horizShadow vertShadow blur color;

.class { text-shadow: 5px 5px 3px #247388; }

Sintaxe

text-shadow

Page 92: Keep calm and let's play CSS3

.class {

text-shadow:

1px 1px 1px #247388,

4px 4px 1px darken(#247388, 5%),

7px 7px 1px darken(#247388, 8%),

10px 10px 1px darken(#247388, 11%),

13px 13px 1px darken(#247388, 14%);

}

text-shadow

Page 93: Keep calm and let's play CSS3

columns

Page 94: Keep calm and let's play CSS3

10 4.0 3.1 11 15

3.2

2.0

mini 7.0 2.1 7.0 11.5

22 35 30 10

Suporte

columns

Page 95: Keep calm and let's play CSS3

column-count: count;

column-gap: gap-value;

column-rule: line-style;

gap

count

rule

Sintaxe

columns

Page 96: Keep calm and let's play CSS3

Prefixos

columns

-webkit-column-count: value;

-moz-column-count: value;

column-count: value;

-webkit-column-gap: value;

-moz-column-gap: value;

column-gap: value;

-webkit-column-rule: value;

-moz-column-rule: value;

column-rule: value;

Page 97: Keep calm and let's play CSS3

@mixin column($count, $gap, $line) {

-webkit-column-count: $count;

-moz-column-count: $count;

column-count: $count;

-webkit-column-gap: $gap;

-moz-column-gap: $gap;

column-gap: $gap;

-webkit-column-rule: $line;

-moz-column-rule: $line;

column-rule: $line;

}

.class { @include column(3, 150px, solid 1px red); }

Mixin

columns

Page 98: Keep calm and let's play CSS3

.class { @include column(3, 150px, solid 1px red); }

columns

Page 99: Keep calm and let's play CSS3

@mixin column($count, $gap, $line:'') {

-webkit-column-count: $count;

-moz-column-count: $count;

column-count: $count;

-webkit-column-gap: $gap;

-moz-column-gap: $gap;

column-gap: $gap;

@if $line != '' {

-webkit-column-rule: $line;

-moz-column-rule: $line;

column-rule: $line;

}

}

Mixin

columns

Page 100: Keep calm and let's play CSS3

.class { @include column(3, 150px); }

columns

Page 101: Keep calm and let's play CSS3

columns

Page 102: Keep calm and let's play CSS3

%full-text {

-webkit-column-span: all;

-moz-column-span: all;

column-span: all;

}

.title { @extend %full-text; }

Placeholder

columns

Page 103: Keep calm and let's play CSS3

gradient

Page 104: Keep calm and let's play CSS3

10 4.0 10

4.0 5.1

11.1 11.6

3.2 5.1

3.6

mini ... 2.1

4.0 7.0 10

11.5 12

35 30 10

Suporte

gradient

Page 105: Keep calm and let's play CSS3

background-color:

linear-gradient(direction, color-stop1, color-stop2, ...);

color-stop1 color-stop2 direction

background: linear-gradient(to right, #4bacc6, #235e6e);

Sintaxe

gradient

Page 106: Keep calm and let's play CSS3

Prefixos

gradient

background: -webkit-gradient(linear, values);

background: -webkit-linear-gradient(values);

background: -moz-linear-gradient(values);

background: -ms-linear-gradient(values);

background: -o-linear-gradient(values);

background: linear-gradient(values);

Page 107: Keep calm and let's play CSS3

@mixin horizontal-gradient($startColor, $endColor) {

background-color: $startColor;

background: -webkit-gradient(

linear, left top, right top,

from($startColor), to($endColor));

background: -webkit-linear-gradient(left, $startColor, $endColor);

background: -moz-linear-gradient(left, $startColor, $endColor);

background: -ms-linear-gradient(left, $startColor, $endColor);

background: -o-linear-gradient(left, $startColor, $endColor);

background: linear-gradient(to right, $startColor, $endColor);

filter:

progid:DXImageTransform.Microsoft.gradient(GradientType=1,StartColor

Str='#{$startColor}', EndColorStr='#{$endColor}');

}

Mixin

gradient

Page 108: Keep calm and let's play CSS3

@mixin vertical-gradient($startColor, $endColor) {

background-color: $startColor;

background: -webkit-gradient(

linear, left top, left bottom,

from($startColor), to($endColor));

background: -webkit-linear-gradient(top, $startColor, $endColor);

background: -moz-linear-gradient(top, $startColor, $endColor);

background: -ms-linear-gradient(top, $startColor, $endColor);

background: -o-linear-gradient(top, $startColor, $endColor);

background: linear-gradient(to bottom, $startColor, $endColor);

filter:

progid:DXImageTransform.Microsoft.gradient(GradientType=0,StartColor

Str='#{$startColor}', EndColorStr='#{$endColor}');

}

Mixin

gradient

Page 109: Keep calm and let's play CSS3

.class { @include horizontal-gradient(#4bacc6, #235e6e); }

gradient

.class { @include vertical-gradient(#4bacc6, #235e6e); }

Page 110: Keep calm and let's play CSS3

transform

Page 111: Keep calm and let's play CSS3

9.0 4.0 3.1 10.5

3.2

3.5

mini ... 2.1 7.0 11.5 35 30 10

Suporte

transform

Page 112: Keep calm and let's play CSS3

transform: transform-function(value);

Prefixos

Sintaxe

transform

-webkit-transform: values;

-moz-transform: values;

-o-transform: values;

-ms-transform: values;

transform: values;

Page 113: Keep calm and let's play CSS3

@mixin transform($parameters) {

-webkit-transform: $parameters;

-moz-transform: $parameters;

-o-transform: $parameters;

-ms-transform: $parameters;

transform: $parameters;

}

transform

Mixin

.class { @include transform(rotate(45deg)); }

.class { @include transform(scale(2)); }

Page 114: Keep calm and let's play CSS3

Translate

@mixin translate($valueX, $valueY: 0) {

-webkit-transform: translate($valueX, $valueY);

-moz-transform: translate($valueX, $valueY);

-o-transform: translate($valueX, $valueY);

-ms-transform: translate($valueX, $valueY);

transform: translate($valueX, $valueY);

}

transform: translate(valueX, valueY); // X e Y

transform: translate(value); // X

transform: translateX(value); // X

transform: translateY(value); // Y

Mixin

transform

Page 115: Keep calm and let's play CSS3

Translate

.class { @include translate(100px, 100px); }

transform

.class { @include transform(translate(100px, 100px)); }

Page 116: Keep calm and let's play CSS3

Translate

.class { @include translate(100px); }

transform

.class { @include transform(translateX(100px)); }

Page 117: Keep calm and let's play CSS3

Skew

@mixin skew($valueX, $valueY) {

-webkit-transform: skewX($valueX) skewY($valueY);

-moz-transform: skewX($valueX) skewY($valueY);

-o-transform: skewX($valueX) skewY($valueY);

-ms-transform: skewX($valueX) skewY($valueY);

transform: skewX($valueX) skewY($valueY);

}

transform: skewX(value) skewY(value);

Mixin

transform

Page 118: Keep calm and let's play CSS3

Skew

.class { @include skew(-25deg, 0); }

transform

.class { @include transform(skewX(-25deg)); }

Page 119: Keep calm and let's play CSS3

Skew

.class { @include skew(0, 25deg); }

transform

.class { @include transform(skewY(25deg)); }

Page 120: Keep calm and let's play CSS3

Transform origin

@mixin origin($valueX, $valueY) {

-webkit-transform-origin: $valueX $valueY;

-moz-transform-origin: $valueX $valueY;

-o-transform-origin: $valueX $valueY;

-ms-transform-origin: $valueX $valueY;

transform-origin: $valueX $valueY;

}

transform-origin: valueX valueY;

Mixin

transform

Page 121: Keep calm and let's play CSS3

Skew | origin

.class {

@include origin(bottom, left);

@include skew(-25deg, 0);

}

transform

Page 122: Keep calm and let's play CSS3

Skew | origin

.class {

@include origin(top, left);

@include skew(0, 25deg);

}

transform

Page 123: Keep calm and let's play CSS3

Scale

@mixin scale($value) {

-webkit-transform: scale($value);

-moz-transform: scale($value);

-o-transform: scale($value);

-ms-transform: scale($value);

transform: scale($value);

}

transform: scale(value); // X e Y iguais

transform: scale(valueY, valueY);

transform: scaleX(value);

transform: scaleY(value);

Mixin

transform

Page 124: Keep calm and let's play CSS3

Scale

.class { @include scale(0.75); }

transform

.class { @include transform(scale(0.75)); }

Page 125: Keep calm and let's play CSS3

Scale | origin

.class {

@include origin(bottom, left);

@include scale(0.75);

}

transform

Page 126: Keep calm and let's play CSS3

Rotate

@mixin rotate($value) {

-webkit-transform: rotate($value);

-moz-transform: rotate($value);

-o-transform: rotate($value);

-ms-transform: rotate($value);

transform: rotate($value);

}

transform: rotate(value);

Mixin

transform

Page 127: Keep calm and let's play CSS3

Rotate

.class { @include rotate(45deg); }

transform

.class { @include transform(rotate(45deg)); }

Page 128: Keep calm and let's play CSS3

Rotate | origin

.class {

@include rotate(45deg);

@include origin(bottom, right);

}

transform

Page 129: Keep calm and let's play CSS3

transition

Page 130: Keep calm and let's play CSS3

10 4.0 3.1 10.5

3.2

4.0

mini ... 2.1 7.0 10 35 30 10

Suporte

transition

Page 131: Keep calm and let's play CSS3

*transition-property: property;

*transition-duration: value;

transition-timing-function: value;

transition-delay: value;

transition: property duration timing-function delay;

Sintaxe

transition

property* duration* timing-function delay

property duration ease 0

ease-in time

ease-out

cubic-

bezier

Page 132: Keep calm and let's play CSS3

@mixin transition($parameters...) {

-webkit-transition: $parameters;

-moz-transition: $parameters;

-o-transition: $parameters;

-ms-transition: $parameters;

transition: $parameters;

}

Mixin

Prefixos

transition

-webkit-transition: values;

-moz-transition: values;

-o-transition: values;

-ms-transition: values;

transition: values;

Page 133: Keep calm and let's play CSS3

.class { @include transition(background-color 1s ease); }

transition

Page 134: Keep calm and let's play CSS3

.class {

@include transition(

background-color 1s ease,

height 1s ease 1s);

}

transition

Page 135: Keep calm and let's play CSS3

animation

Page 136: Keep calm and let's play CSS3

10 4.0 4.0 12

3.2

5.0

mini ... 2.1

4.0 7.0 12.1 35 30 10

Suporte

animation

Page 137: Keep calm and let's play CSS3

@keyframes animacao {

from { ... }

to { ... }

}

@keyframes animacaoBolada {

0% { ... }

50% { ... }

100% { ... }

}

maior controle

porcentagem relativa à duração da animação

forma mais básica

Keyframes

animation

Page 138: Keep calm and let's play CSS3

Keyframes - Prefixos

animation

@-webkit-keyframes animationName { }

@-moz-keyframes animationName { }

@-o-keyframes animationName { }

@-ms-keyframes animationName { }

@keyframes animationName { }

Page 139: Keep calm and let's play CSS3

@mixin keyframes($name) {

@-webkit-keyframes $name {

@content;

}

@-moz-keyframes $name {

@content;

}

@-ms-keyframes $name {

@content;

}

@-o-keyframes $name {

@content;

}

@keyframes $name {

@content;

}

}

Keyframes - Mixin

animation

Page 140: Keep calm and let's play CSS3

@include keyframes(animationOne) {

from { background-color: #2d839a; }

to { background-color: #0f282f; }

}

@include keyframes(animationTwo) {

0% { background-color: #2d839a; }

50% {

background-color: #72e1ff;

height: 400px;

}

100% { background-color: #0f282f; }

}

Keyframes

animation

Page 141: Keep calm and let's play CSS3

*animation-name: name;

*animation-duration: value;

animation-timing-function: ease|ease-out …;

animation-delay: value;

animation-iteration-count: value|infinite;

animation-direction: normal|reverse|alternate|

alternate-reverse;

animation-fill-mode: forwards|backwards|both;

animation-play-state: running|paused;

animation: name duration timing-function

delay iteration-count direction

fill-mode play-state;

Sintaxe

animation

Page 142: Keep calm and let's play CSS3

Sintaxe

animation

name* duration* timing-

function delay

iteration-count

direction fill-mode play-state

name duration ease 0 1 normal none running

ease-in time infinite alternate forwards paused

ease-out value reverse backward

s

cubic-

bezier alternate

-reverse both

Page 143: Keep calm and let's play CSS3

-webkit-animation: values;

-moz-animation: values;

-ms-animation: values;

-o-animation: values;

animation: values;

Prefixos

animation

@mixin animation($parameters...) {

-webkit-animation: $parameters;

-moz-animation: $parameters;

-ms-animation: $parameters;

-o-animation: $parameters;

animation: $parameters;

}

Mixin

Page 144: Keep calm and let's play CSS3

.class { @include animation(animationOne 3s); }

animation-name: animationOne;

animation-duration: 3s;

animation-timing-function: ease;

animation-delay: 0;

animation-iteration-count: 1;

animation-direction: normal;

animation-fill-mode: none;

animation-play-state: running;

animation

Page 145: Keep calm and let's play CSS3

timing-function

animation

http://bit.ly/timing-function

.class-a { @include animation(animationHeight 1.5s); }

.class-b { @include animation(animationHeight 1.5s ease-in); }

.class-c { @include animation(animationHeight 1.5s ease-out); }

.class-d { @include animation(animationHeight 1.5s cubic-

bezier(0.680, -0.550, 0.265, 1.550)); }

Page 146: Keep calm and let's play CSS3

iteration-count

animation

http://bit.ly/iteration-count

.class-a { @include animation(animationHeight 1.5s); }

.class-b { @include animation(animationHeight 1.5s 3); }

.class-c { @include animation(animationHeight 1.5s infinite); }

Page 147: Keep calm and let's play CSS3

direction

animation

http://bit.ly/anim-direction

.class-a { @include animation(animationHeight 1.5s infinite); }

.class-b { @include animation(animationHeight 1.5s infinite reverse); }

.class-c { @include animation(animationHeight 1.5s infinite alternate); }

.class-d { @include animation(animationHeight 1.5s infinite alternate-

reverse); }

Page 148: Keep calm and let's play CSS3

fill-mode

@include keyframes(animationFill) {

from {

height: 300px;

background-color: #2d839a;

}

to {

height: 450px;

background-color: #0f282f;

}

}

.class {

background-color: yellow;

width: 300px;

height: 300px;

margin-left: 25px;

margin-right: 25px;

}

animation

Page 149: Keep calm and let's play CSS3

fill-mode

animation

http://bit.ly/fill-mode

.class-a { @include animation(animationFill 2s 1.5s); }

.class-b { @include animation(animationFill 2s 1.5s forwards); }

.class-c { @include animation(animationFill 2s 1.5s backwards); }

.class-d { @include animation(animationFill 2s 1.5s both); }

Page 150: Keep calm and let's play CSS3

Dicas

Page 151: Keep calm and let's play CSS3

http://caniuse.com/

Page 152: Keep calm and let's play CSS3

http://bit.ly/transition-snippets

Page 153: Keep calm and let's play CSS3

http://matthewlein.com/ceaser/

Page 154: Keep calm and let's play CSS3

http://bit.ly/sass-mixins

Page 155: Keep calm and let's play CSS3

aprenda CSS antes de pré processadores

use com moderação

todos prefixos

CSS3 não tem a ver com o Brasil na copa ¯\_(ツ)_/¯

Page 156: Keep calm and let's play CSS3

@raphaelfabeni

Obrigado!

[email protected]