css motion code example

Example 1: css animation

<style>
.my-element {
  width: 100%;
  height: 100%;
  animation: tween-color 5s infinite;
}

@keyframes tween-color {
  0% {
    background-color: red;
  }
  50% {
    background-color: green;
  }
  100% {
    background-color: red;
  }
}

html,
body {
  height: 100%;
}
<style>

<body>
	<div class="my-element"></div>
</body>

Example 2: css animation

CSS animation properties template:
{
   animation-name: anima-name;
    animation-duration: 1s;
    animation-iteration-count: infinite;
    animation-delay: 2s;
    animation-direction: reverse | normal | alternate | alternate-reverse ; 
  animation-timing-function: ease | ease-out | ease-in | ease-in-out | linear | cubic-bezier(x1, y1, x2, y2) (e.g. cubic-bezier(0.5, 0.2, 0.3, 1.0)); 
  animation-fill-mode:forwards | backwards | both | none;
}
@keyframes anima-name {
  from {
   background-position:right;
  }
  to {
    background-position:left;
  }
}
@keyframes anima-name {
  0% {
    background-color: red;
  }
  50% {
    background-color: green;
  }
  100% {
    background-color: red;
  }
}

Example 3: webkit animation

@-webkit-keyframes pulse {
 0% {
   background-color: red;
   opacity: 1.0;
   -webkit-transform: scale(1.0) rotate(0deg);
 }
 33% {
   background-color: blue;
   opacity: 0.75;
   -webkit-transform: scale(1.1) rotate(-5deg);
 }
 67% {
   background-color: green;
   opacity: 0.5;
   -webkit-transform: scale(1.1) rotate(5deg);
 }
 100% {
   background-color: red;
   opacity: 1.0;
   -webkit-transform: scale(1.0) rotate(0deg);
 }
}

.pulsedbox {
 -webkit-animation-name: pulse;
 -webkit-animation-duration: 4s;
 -webkit-animation-direction: alternate;
 -webkit-animation-timing-function: ease-in-out;
}

Example 4: css animation

Read this helpful, short and straightforward article to learn CSS animation perfectly.

https://medium.com/@Cafe_Code/learn-css-animation-asap-as-simple-as-possible-374b7874d4dd

Tags:

Html Example