Approfondissement CSS3

104

description

Mon second workshop à propos de CSS3. Veille HTML5/CSS3 sur Twitter: @FGRibreau N'hésitez pas à me faire parvenir vos corrections et suggestions :) Démonstrations (Safari/Chrome seulement): http://projets.geekfg.net/?/10 http://projets.geekfg.net/?/11

Transcript of Approfondissement CSS3

Page 1: Approfondissement CSS3
Page 2: Approfondissement CSS3
Page 3: Approfondissement CSS3

Welcome !

http://bit.ly/a5PMFHLe code est disponible ici:

Le zip est disponible ici: http://bit.ly/cqp7EX

Page 4: Approfondissement CSS3

fgribreau.com

Page 5: Approfondissement CSS3

<CSS3>

Page 6: Approfondissement CSS3

... lors de la dernière conférence

Page 8: Approfondissement CSS3

Le sujet de ce soir...

Page 9: Approfondissement CSS3
Page 10: Approfondissement CSS3
Page 11: Approfondissement CSS3

Un div = un calque = une image animée

Page 12: Approfondissement CSS3

Côté HTML

Page 13: Approfondissement CSS3

Côté HTML

(function($)  {   window.app  =  {     init:  function()  {       $('#bird')         .sprite({fps:  9,  no_of_frames:  3})         .activeOnClick()         .active();       $('#bird2')         .sprite({fps:  12,  no_of_frames:  3})         .activeOnClick();

      $('html').flyToTap();       if  (window.Touch  ||  document.location.hash.indexOf('iphone')  >  -­‐1)  {         //  iPhone/iPad         $('body').addClass('platform-­‐iphone');         //  bird  constraint  is  slightly  smaller         $('#bird').spRandom({top:  -­‐10,  left:  -­‐10,  right:  150,  bottom:  100,  speed:  3500,  pause:  5000});         $('#bird2').spRandom({top:  70,  left:  100,  right:  200,  bottom:  340,  speed:  4000,  pause:  3000});         if  (document.location.hash.indexOf('iphone')  >  -­‐1)  {           $('body').addClass('platform-­‐iphone');         }       }  else  {         //  non-­‐iPhone         //  bird  constraint  is  slightly  wider         var  stage_left  =  (($('body').width()  -­‐  866)  /  2);         var  stage_top  =  30;         $('#bird').spRandom({top:  stage_top  -­‐  20,  left:  stage_left  -­‐  20,  right:  400,  bottom:  140,  speed:  3500,  pause:  5000});         $('#bird2').spRandom({top:  stage_top  +  70,  left:  stage_left  +  100,  right:  200,  bottom:  340,  speed:  4000,  pause:  3000});       }           },

Côté jQuery (javascript)

$('#clouds').pan({fps:  30,  speed:  0.7,  dir:  'left'});$('#hill2').pan({fps:  30,  speed:  2,  dir:  'left'});$('#hill1').pan({fps:  30,  speed:  3,  dir:  'left'});

Page 14: Approfondissement CSS3

Côté HTML

Côté jQuery (javascript)

$('#clouds').pan({fps:  30,  speed:  0.7,  dir:  'left'});$('#hill2').pan({fps:  30,  speed:  2,  dir:  'left'});$('#hill1').pan({fps:  30,  speed:  3,  dir:  'left'});

Page 15: Approfondissement CSS3
Page 16: Approfondissement CSS3

Javascript ? jQuery ? (Flash ? ... lol)

Page 17: Approfondissement CSS3

Javascript ? jQuery ? (Flash ? ... lol)

Page 18: Approfondissement CSS3

Javascript ? jQuery ? (Flash ? ... lol)

FTW

C S S 3 s t y l e !

Page 19: Approfondissement CSS3

Les nuages (#clouds)

Eléments à animer en CSS3

Colline 2 (#hill2)

Colline 1 (#hill1)

Logo (#logo)

Page 20: Approfondissement CSS3
Page 21: Approfondissement CSS3

Animation des nuages #clouds

Page 22: Approfondissement CSS3

Les nuages

background-­‐position:  0px  102px;

Page 23: Approfondissement CSS3

Les nuages

background-­‐position:  0px  102px;

background-­‐position:  -­‐1068px  102px;

Page 24: Approfondissement CSS3

Les nuages

background-­‐position:  0px  102px;

background-­‐position:  -­‐1068px  102px;

Page 25: Approfondissement CSS3

<keyframes>

Page 26: Approfondissement CSS3

keyframe : type d’animation mémorisant des positions fixes et qui calculera ensuite

les emplacements intermédiaires.

Page 27: Approfondissement CSS3

Les keyframes en CSS3

@keyframes  nomAnimation{0%        {propriété:  valeur;}100%    {propriété:  valeur;}

}

http://bit.ly/a5PMFH

Page 28: Approfondissement CSS3

Les keyframes en CSS3

@keyframes  nomAnimation{0%        {propriété:  valeur;}100%    {propriété:  valeur;}

}=from

to

http://bit.ly/a5PMFH

Page 29: Approfondissement CSS3

Les keyframes en CSS3

@keyframes  nomAnimation{0%        {propriété:  valeur;}100%    {propriété:  valeur;}

}

@keyframes  animClouds{                0%        {background-­‐position:  0px  102px;  }                100%    {background-­‐position:  -­‐1068px  102px;  }}

=fromto

http://bit.ly/a5PMFH

Page 30: Approfondissement CSS3

Les keyframes en CSS3

@keyframes  nomAnimation{0%        {propriété:  valeur;}100%    {propriété:  valeur;}

}

@keyframes  animClouds{                0%        {background-­‐position:  0px  102px;  }                100%    {background-­‐position:  -­‐1068px  102px;  }}

@-­‐webkit-­‐keyframes  animClouds{                0%        {background-­‐position:  0px  102px;  }                100%    {background-­‐position:  -­‐1068px  102px;  }}

=fromto

http://bit.ly/a5PMFH

Page 31: Approfondissement CSS3

4+

@-­‐webkit-­‐keyframes

Keyframes CSS3

Page 32: Approfondissement CSS3

</keyframes>

Page 33: Approfondissement CSS3

<animation>

Page 34: Approfondissement CSS3

#clouds {

}

animation-name: animClouds;

http://bit.ly/a5PMFH

Page 35: Approfondissement CSS3

#clouds {

}

animation-duration: 70s; animation-name: animClouds;

http://bit.ly/a5PMFH

Page 36: Approfondissement CSS3

#clouds {

}

animation-timing-function: linear;animation-duration: 70s; animation-name: animClouds;

http://bit.ly/a5PMFH

Page 37: Approfondissement CSS3

#clouds {

}

animation-timing-function: linear;animation-duration: 70s; animation-name: animClouds;

animation-iteration-count: infinite;

http://bit.ly/a5PMFH

Page 38: Approfondissement CSS3

#clouds {

}

animation-timing-function: linear;animation-duration: 70s; animation-name: animClouds;

animation-iteration-count: infinite;

-webkit--webkit--webkit--webkit-

http://bit.ly/a5PMFH

Page 39: Approfondissement CSS3

6 lignes de CSS3 pour l’animation des nuages

Page 40: Approfondissement CSS3
Page 41: Approfondissement CSS3

Animation de la colline n°2 #hill2

Page 42: Approfondissement CSS3

Colline n°2

background-­‐position:  0px  258px;

Page 43: Approfondissement CSS3

Colline n°2

background-­‐position:  0px  258px;

background-­‐position:  -­‐1110px  258px;

Page 44: Approfondissement CSS3

Colline n°2

background-­‐position:  0px  258px;

background-­‐position:  -­‐1110px  258px;

Page 45: Approfondissement CSS3

@-­‐webkit-­‐keyframes  animHill2{                0%        {background-­‐position:  0px  258px;  }                100%    {background-­‐position:  -­‐1110px  258px;  }}

http://bit.ly/a5PMFH

Page 46: Approfondissement CSS3

#hill2 {

}

animation-timing-function: linear;

animation-duration: 25s;

animation-name: animHill2;

animation-iteration-count: infinite;

-webkit-

-webkit-

-webkit-

-webkit-

http://bit.ly/a5PMFH

Page 47: Approfondissement CSS3

#hill2 {

}

animation-timing-function: linear;

animation-duration: 25s;

animation-name: animHill2;

animation-iteration-count: infinite;

-webkit-

-webkit-

-webkit-

-webkit- ?http://bit.ly/a5PMFH

Page 48: Approfondissement CSS3

#hill2 {

}

animation-timing-function: linear;

animation-duration: 25s;

animation-name: animHill2;

animation-iteration-count: infinite;

-webkit-

-webkit-

-webkit-

-webkit- ?

Page 49: Approfondissement CSS3

#hill2 {

}

animation-timing-function: linear;

animation-duration: 25s;

animation-name: animHill2;

animation-iteration-count: infinite;

-webkit-

-webkit-

-webkit-

-webkit- ?animation: [<animation-name> || <animation-duration> || <animation-timing-function> || <animation-delay> || <animation-iteration-count> || <animation-direction>] [, [<animation-name> || <animation-duration> || <animation-timing-function> || <animation-delay> || <animation-iteration-count> || <animation-direction>] ]*

Page 50: Approfondissement CSS3

#hill2 {

}

animation-timing-function: linear;

animation-duration: 25s;

animation-name: animHill2;

animation-iteration-count: infinite;

-webkit-

-webkit-

-webkit-

-webkit-

http://bit.ly/a5PMFH

Page 51: Approfondissement CSS3

#hill2 {

}

animation-timing-function: linear;

animation-duration: 25s;

animation-name: animHill2;

animation-iteration-count: infinite;

-webkit-

-webkit-

-webkit-

-webkit-

-webkit-#hill2 {

}animation: animHill2 25s linear 0s infinite;

http://bit.ly/a5PMFH

Page 52: Approfondissement CSS3

4+

-­‐webkit-­‐animation

Animation CSS3

4+?

Page 53: Approfondissement CSS3
Page 54: Approfondissement CSS3

Animation de la colline n°1 #hill1

Page 55: Approfondissement CSS3

@-­‐webkit-­‐keyframes  animHill1{                0%        {background-­‐position:  0px  104px;  }                100%    {background-­‐position:  -­‐2220px  104px;  }}

Page 56: Approfondissement CSS3

@-­‐webkit-­‐keyframes  animHill1{                0%        {background-­‐position:  0px  104px;  }                100%    {background-­‐position:  -­‐2220px  104px;  }}

#hill1 {

}animation: animHill1 25s linear 2s infinite;

Page 57: Approfondissement CSS3

</animation>

Page 58: Approfondissement CSS3

<transition>

Page 59: Approfondissement CSS3

<p>Hello  world</p>

Transition CSS3

Page 60: Approfondissement CSS3

Hello world

<p>Hello  world</p>

p{color:  #00FF00;

}

Transition CSS3

Page 61: Approfondissement CSS3

Hello world Hello world

<p>Hello  world</p>

p{color:  #00FF00;

}

p:hover{color:  #0000FF;

}

Transition CSS3

Page 62: Approfondissement CSS3

Hello world Hello world

<p>Hello  world</p>

p{color:  #00FF00;

}

p:hover{color:  #0000FF;

}

Transition CSS3

transition css3

Page 63: Approfondissement CSS3

p{color:  #00FF00;

}

p:hover{color:  #0000FF;

}

Hello world Hello worldtransition css3

transition: [<transition-property> || <transition-duration> || <transition-timing-function> || <transition-delay> [, [<transition-property> || <transition-

duration> || <transition-timing-function> || <transition-delay>]]*

Page 64: Approfondissement CSS3

p{color:  #00FF00;

}

p:hover{color:  #0000FF;

}

Hello world Hello worldtransition css3

Page 65: Approfondissement CSS3

transition:color 500ms ease-in 1s;

p{color:  #00FF00;

}

p:hover{color:  #0000FF;

}

Hello world Hello worldtransition css3

-webkit-

Page 66: Approfondissement CSS3

transition:color 500ms ease-in 1s;

p{color:  #00FF00;

}

p:hover{color:  #0000FF;

}

Hello world Hello world

-webkit-

transition css3

Page 67: Approfondissement CSS3

p{color:  #00FF00;

}

p:hover{color:  #0000FF;

}

Hello world Hello world

Page 68: Approfondissement CSS3

p{color:  #00FF00;

}

p:hover{color:  #0000FF;

}

Hello world Hello worldtransition css3

Page 69: Approfondissement CSS3

Transitions CSS3

Page 70: Approfondissement CSS3

Transitions CSS3

Page 71: Approfondissement CSS3

3.7+

10.5+

4+

-­‐moz-­‐transition

-­‐o-­‐transition

-­‐webkit-­‐transition

Transitions CSS3

Page 72: Approfondissement CSS3

</transition>

Page 73: Approfondissement CSS3

<box-­‐sizing>

Page 74: Approfondissement CSS3

.monDiv

100px

.monDiv{   width:100px;}

Facile...

Box-sizing CSS3

Page 75: Approfondissement CSS3

100px

.monDiv{width:100px;padding:5px;

}

.monDiv

110px

Facile...

Box-sizing CSS3

Page 76: Approfondissement CSS3

100px

.monDiv{width:100px;padding:10px;border-­‐width:20px;

}

.monDiv

120px

Gênant...

160px

Box-sizing CSS3

Page 77: Approfondissement CSS3

Solution ? please :’(

Page 78: Approfondissement CSS3

100px

.monDiv

120px

160px

Sans<=>  (Box-­‐sizing:  content-­‐box)

Avec Box-­‐sizing:  border-­‐box

Box-sizing CSS3.monDiv{width:100px;  padding:10px;  border-­‐width:20px;}

.monDiv

60px

80px

100px

Page 79: Approfondissement CSS3

8+

1+

7+

3+

-­‐moz-­‐box-­‐sizing

box-­‐sizing

-­‐webkit-­‐box-­‐sizing

box-­‐sizing

Box-sizing CSS3

Page 80: Approfondissement CSS3

</box-­‐sizing>

Page 81: Approfondissement CSS3

<rgba>

Page 82: Approfondissement CSS3

.monDiv

.monDiv{   background-­‐color:rgb(0,  130,  229);}

RGBA CSS3

R V B

Page 83: Approfondissement CSS3

.monDiv

.monDiv{   background-­‐color:rgba(0,  130,  229,  0.8);}

RGBA CSS3

R V B Alpha

Page 84: Approfondissement CSS3

2+

10+

3.1+

rgba

rgba

rgba

RGBA CSS3

Page 85: Approfondissement CSS3

</rgba>

Page 86: Approfondissement CSS3
Page 87: Approfondissement CSS3

Animation du Logo #logo

Page 88: Approfondissement CSS3

Nous allons voir besoin de :

Page 89: Approfondissement CSS3

Transition CSS3

Nous allons voir besoin de :

Page 90: Approfondissement CSS3

Transition CSS3

RGBA

Nous allons voir besoin de :

Page 91: Approfondissement CSS3

Transition CSS3

Box-sizing

RGBA

Nous allons voir besoin de :

Page 92: Approfondissement CSS3

http://bit.ly/a5PMFH

Page 93: Approfondissement CSS3

http://bit.ly/a5PMFH

Page 94: Approfondissement CSS3

http://bit.ly/a5PMFH

Page 95: Approfondissement CSS3

http://bit.ly/a5PMFH

Page 96: Approfondissement CSS3

http://bit.ly/a5PMFH

Page 97: Approfondissement CSS3

http://bit.ly/a5PMFH

Page 98: Approfondissement CSS3

Et voila !

Page 101: Approfondissement CSS3

</CSS3>

Page 102: Approfondissement CSS3

Ne vous arrêtez pas à cet exposé ! (please!)

Page 103: Approfondissement CSS3

Ne vous arrêtez pas à cet exposé ! (please!)

http://fgribreau.com

Page 104: Approfondissement CSS3

Ne vous arrêtez pas à cet exposé ! (please!)

http://fgribreau.comhttp://blog.geekfg.net/