Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CSS3 Transforms Transitions and Animations

FEVR
September 25, 2014

CSS3 Transforms Transitions and Animations

FEVR

September 25, 2014
Tweet

More Decks by FEVR

Other Decks in Technology

Transcript

  1. Transform The transform property applies a 2D or 3D transformation

    to an element. This property allows you to rotate, scale, move, skew, etc., elements.
  2. Transform: scale .square { height: 250px; width: 250px; background-color: orange;

    } becomes .square { height: 250px; width: 250px; background-color: orange; transform: scale(2); }
  3. Transform: rotate & skew .square { height: 250px; width: 250px;

    background-color: orange; transform: rotate(45deg); } .square { height: 250px; width: 250px; background-color: orange; transform: skew(45deg); }
  4. Transform: translate .square { height: 250px; width: 250px; background-color: orange;

    } becomes .square { height: 250px; width: 250px; background-color: orange; transform: translate(50px,50px); }
  5. Multiple Transforms .square { height: 250px; width: 250px; background-color: orange;

    } becomes .square { height: 250px; width: 250px; background-color: orange; transform: scale(2) rotate(45deg); }
  6. Transform origin the default transform origin is the dead center

    of an element, both 50% horizontally and 50% vertically. .square { transform: rotate(45deg); transform-origin: right top; } .square { transform: rotate(45deg); transform-origin: 100% 100%; }
  7. Transition properties .square { //name of the CSS property the

    transition effect is for transition-property: width; //how many seconds or milliseconds a transition effect takes to complete transition-duration: 1s; //the speed curve of the transition effect transition-timing-function: linear; //when the transition effect will start transition-delay: 2s; } .square { transition: width 1s linear 2s; }
  8. Transition timing function LINEAR same speed from start to end

    EASE IN-OUT slow start and end EASE OUT slow end EASE IN slow start
  9. Animation CSS Animation is like transitions, however we can specify

    the number of times it plays and whether it plays in a single direction or both directions They are named and can be reusable by more than one css rule
  10. Animation Example .square { height: 60px; width: 60px; animation: ‘moveit’

    4s ease 3 normal; } @-webkit-keyframes ‘moveit’ { 0% { width: 200px; background: red; opacity: 0.5 transform: scale(.5) rotate(15deg); } 50% { width: 300px; background: red; opacity: 1 transform: scale(1.3) rotate(15deg); } 100% { width: 500px; background: yellow; opacity: 0,5 transform: scale(1) rotate(0deg); } }
  11. Animation Values animation: ‘moveit’ 4s ease 3 normal; animation-name: ‘moveit’

    animation-duration: time animation-timing-function: linear/ease/ease-in/ease-out/ease-in-out animation-iteration-count: number or infinite animation-direction: normal or alternate animation-delay: time animation-fill-mode: backwards/forwards/none/both //Configures what values are applied by the animation before and after it is executing.