css transition animation code example

Example 1: css transition opacity

/* Answer to: "css transition opacity" */

/*
  CSS transitions allows you to change property values smoothly,
  over a given duration.
*/

.myClass {
  vertical-align: top;
  transition: opacity 0.3s; /* Transition should take 0.3s */
  -webkit-transition: opacity 0.3s; /* Transition should take 0.3s */
  opacity: 1; /* Set opacity to 1 */
}

.myClass:hover {
  opacity: 0.5; /* On hover, set opacity to 2 */
}

/* 
  From `opacity: 1;` to `opacity: 0.5;`, the transition time should
  take 0.3 seconds as soon as the client starts to hover over the
  element.
*/

Example 2: transition transform

/* Transition Transform */
.section:hover {
  transform: translateX(0px) translateY(75px);
}

.section {
  transition: transform 500ms ease-in-out 25ms;
}

Example 3: css transition

/*CSS Transition Syntax*/
selector {
 transition: property duration timing-function delay|initial|inherit; 
}

Example 4: html transition

html.color-theme-in-transition,
html.color-theme-in-transition *,
html.color-theme-in-transition *:before,
html.color-theme-in-transition *:after {
	transition: all 750ms !important;  
    transition-delay: 0 !important;
}

Example 5: transition syntax css

transition: property duration transition-timing-function delay; 
/*Shorthand Property*/

Example 6: Using CSS transitions

div {
    transition: <property> <duration> <timing-function> <delay>;
}

Tags:

Misc Example