animation-timing-function



значения свойства:


  • linear
  • ease
  • ease-in
  • ease-out
  • ease-in-out
  • cubic-bezier(n,n,n,n)



css/style.css
  • * {
  •  margin: 0;
  •  padding: 0;
  • }
  •  
  • .main {
  •  height: 600px;
  •  width: 900px;
  •  position: absolute;
  •  top: 50%;
  •  left: 50%;
  •  margin-top: -300px;
  •  margin-left: -450px;
  • }
  •  
  • .wrapper {
  •  width: 33.3%;
  •  height: 100%;
  •  float: left;
  • }
  •  
  • #div1, #div2, #div3 {
  •  height: 100px;
  •  width: 100px;
  •  float: left;
  •  position: relative;
  •  top: 50%;
  •  left: 50%;
  •  margin-top: -50px;
  •  margin-left: -50px;
  •  animation-duration: 3s;
  •  -moz-animation-duration: 3s;
  •  -o-animation-duration: 3s;
  •  -webkit-animation-duration: 3s;
  •  animation-iteration-count: infinite;
  •  -moz-animation-iteration-count: infinite;
  •  -o-animation-iteration-count: infinite;
  •  -webkit-animation-iteration-count: infinite;
  •  animation-direction: alternate;
  •  -moz-animation-direction: alternate;
  •  -o-animation-direction: alternate;
  •  -webkit-animation-direction: alternate;
  • }
  •  
  • #div1 {
  •  animation-name: anim1;
  •  -moz-animation-name: anim1;
  •  -o-animation-name: anim1;
  •  -webkit-animation-name: anim1;
  •  animation-timing-function: ease-in;
  •  -moz-animation-timing-function: ease-in;
  •  -o-animation-timing-function: ease-in;
  •  -webkit-animation-timing-function: ease-in;
  • }
  •  
  • @keyframes anim1 {
  •  from {
  •   background-color: #3BA9DE;
  •  }
  •  to {
  •   top: 80px;
  •   left: -10px;
  •   background-color: #A3E61D;
  •  }
  • }
  •  
  • @-moz-keyframes anim1 {
  •  from {
  •   background-color: #3BA9DE;
  •  }
  •  to {
  •   top: 80px;
  •   left: -10px;
  •   background-color: #A3E61D;
  •  }
  • }
  •  
  • @-o-keyframes anim1 {
  •  from {
  •   background-color: #3BA9DE;
  •  }
  •  to {
  •   top: 80px;
  •   left: -10px;
  •   background-color: #A3E61D;
  •  }
  • }
  •  
  • @-webkit-keyframes anim1 {
  •  from {
  •   background-color: #3BA9DE;
  •  }
  •  to {
  •   top: 80px;
  •   left: -10px;
  •   background-color: #A3E61D;
  •  }
  • }
  •  
  • #div2 {
  •  animation-name: anim2;
  •  -moz-animation-name: anim2;
  •  -o-animation-name: anim2;
  •  -webkit-animation-name: anim2;
  •  -moz-animation-timing-function: ease-out;
  •  -o-animation-timing-function: ease-out;
  •  -webkit-animation-timing-function: ease-out;
  • }
  •  
  • @keyframes anim2 {
  •  from {
  •   background-color: #A3E61D;
  •  }
  •  to {
  •   transform: scale(1.8, 1.8);
  •   -moz-transform: scale(1.8, 1.8);
  •   -o-transform: scale(1.8, 1.8);
  •   -webkit-transform: scale(1.8, 1.8);
  •   -ms-transform: scale(1.8, 1.8);
  •   background-color: #852E76;
  •  }
  • }
  •  
  • @-moz-keyframes anim2 {
  •  from {
  •   background-color: #A3E61D;
  •  }
  •  to {
  •   transform: scale(1.8, 1.8);
  •   -moz-transform: scale(1.8, 1.8);
  •   -o-transform: scale(1.8, 1.8);
  •   -webkit-transform: scale(1.8, 1.8);
  •   -ms-transform: scale(1.8, 1.8);
  •   background-color: #852E76;
  •  }
  • }
  •  
  • @-o-keyframes anim2 {
  •  from {
  •   background-color: #A3E61D;
  •  }
  •  to {
  •   transform: scale(1.8, 1.8);
  •   -moz-transform: scale(1.8, 1.8);
  •   -o-transform: scale(1.8, 1.8);
  •   -webkit-transform: scale(1.8, 1.8);
  •   -ms-transform: scale(1.8, 1.8);
  •   background-color: #852E76;
  •  }
  • }
  •  
  • @-webkit-keyframes anim2 {
  •  from {
  •   background-color: #A3E61D;
  •  }
  •  to {
  •   transform: scale(1.8, 1.8);
  •   -moz-transform: scale(1.8, 1.8);
  •   -o-transform: scale(1.8, 1.8);
  •   -webkit-transform: scale(1.8, 1.8);
  •   -ms-transform: scale(1.8, 1.8);
  •   background-color: #852E76;
  •  }
  • }
  •  
  • #div3 {
  •  animation-name: anim3;
  •  -moz-animation-name: anim3;
  •  -o-animation-name: anim3;
  •  -webkit-animation-name: anim3;
  • }
  •  
  • @keyframes anim3 {
  •  from {
  •   top: 300px;
  •   background-color: #3BA9DE;
  •  }
  •  to {
  •   top: 520px;
  •   left: 310px;
  •   background-color: #A3E61D;
  •  }
  • }
  •  
  • @-moz-keyframes anim3 {
  •  from {
  •   top: 300px;
  •   background-color: #3BA9DE;
  •  }
  •  to {
  •   top: 520px;
  •   left: 310px;
  •   background-color: #A3E61D;
  •  }
  • }
  •  
  • @-o-keyframes anim3 {
  •  from {
  •   top: 300px;
  •   background-color: #3BA9DE;
  •  }
  •  to {
  •   top: 520px;
  •   left: 310px;
  •   background-color: #A3E61D;
  •  }
  • }
  •  
  • @-webkit-keyframes anim3 {
  •  from {
  •   top: 300px;
  •   background-color: #3BA9DE;
  •  }
  •  to {
  •   top: 520px;
  •   left: 310px;
  •   background-color: #A3E61D;
  •  }
  • }
* {
 margin: 0;
 padding: 0;
}

.main {
 height: 600px;
 width: 900px;
 position: absolute;
 top: 50%;
 left: 50%;
 margin-top: -300px;
 margin-left: -450px;
}

.wrapper {
 width: 33.3%;
 height: 100%;
 float: left;
}

#div1, #div2, #div3 {
 height: 100px;
 width: 100px;
 float: left;
 position: relative;
 top: 50%;
 left: 50%;
 margin-top: -50px;
 margin-left: -50px;
 animation-duration: 3s;
 -moz-animation-duration: 3s;
 -o-animation-duration: 3s;
 -webkit-animation-duration: 3s;
 animation-iteration-count: infinite;
 -moz-animation-iteration-count: infinite;
 -o-animation-iteration-count: infinite;
 -webkit-animation-iteration-count: infinite;
 animation-direction: alternate;
 -moz-animation-direction: alternate;
 -o-animation-direction: alternate;
 -webkit-animation-direction: alternate;
}

#div1 {
 animation-name: anim1;
 -moz-animation-name: anim1;
 -o-animation-name: anim1;
 -webkit-animation-name: anim1;
 animation-timing-function: ease-in;
 -moz-animation-timing-function: ease-in;
 -o-animation-timing-function: ease-in;
 -webkit-animation-timing-function: ease-in;
}

@keyframes anim1 {
 from {
  background-color: #3BA9DE;
 }
 to {
  top: 80px;
  left: -10px;
  background-color: #A3E61D;
 }
}

@-moz-keyframes anim1 {
 from {
  background-color: #3BA9DE;
 }
 to {
  top: 80px;
  left: -10px;
  background-color: #A3E61D;
 }
}

@-o-keyframes anim1 {
 from {
  background-color: #3BA9DE;
 }
 to {
  top: 80px;
  left: -10px;
  background-color: #A3E61D;
 }
}

@-webkit-keyframes anim1 {
 from {
  background-color: #3BA9DE;
 }
 to {
  top: 80px;
  left: -10px;
  background-color: #A3E61D;
 }
}

#div2 {
 animation-name: anim2;
 -moz-animation-name: anim2;
 -o-animation-name: anim2;
 -webkit-animation-name: anim2;
 -moz-animation-timing-function: ease-out;
 -o-animation-timing-function: ease-out;
 -webkit-animation-timing-function: ease-out;
}

@keyframes anim2 {
 from {
  background-color: #A3E61D;
 }
 to {
  transform: scale(1.8, 1.8);
  -moz-transform: scale(1.8, 1.8);
  -o-transform: scale(1.8, 1.8);
  -webkit-transform: scale(1.8, 1.8);
  -ms-transform: scale(1.8, 1.8);
  background-color: #852E76;
 }
}

@-moz-keyframes anim2 {
 from {
  background-color: #A3E61D;
 }
 to {
  transform: scale(1.8, 1.8);
  -moz-transform: scale(1.8, 1.8);
  -o-transform: scale(1.8, 1.8);
  -webkit-transform: scale(1.8, 1.8);
  -ms-transform: scale(1.8, 1.8);
  background-color: #852E76;
 }
}

@-o-keyframes anim2 {
 from {
  background-color: #A3E61D;
 }
 to {
  transform: scale(1.8, 1.8);
  -moz-transform: scale(1.8, 1.8);
  -o-transform: scale(1.8, 1.8);
  -webkit-transform: scale(1.8, 1.8);
  -ms-transform: scale(1.8, 1.8);
  background-color: #852E76;
 }
}

@-webkit-keyframes anim2 {
 from {
  background-color: #A3E61D;
 }
 to {
  transform: scale(1.8, 1.8);
  -moz-transform: scale(1.8, 1.8);
  -o-transform: scale(1.8, 1.8);
  -webkit-transform: scale(1.8, 1.8);
  -ms-transform: scale(1.8, 1.8);
  background-color: #852E76;
 }
}

#div3 {
 animation-name: anim3;
 -moz-animation-name: anim3;
 -o-animation-name: anim3;
 -webkit-animation-name: anim3;
}

@keyframes anim3 {
 from {
  top: 300px;
  background-color: #3BA9DE;
 }
 to {
  top: 520px;
  left: 310px;
  background-color: #A3E61D;
 }
}

@-moz-keyframes anim3 {
 from {
  top: 300px;
  background-color: #3BA9DE;
 }
 to {
  top: 520px;
  left: 310px;
  background-color: #A3E61D;
 }
}

@-o-keyframes anim3 {
 from {
  top: 300px;
  background-color: #3BA9DE;
 }
 to {
  top: 520px;
  left: 310px;
  background-color: #A3E61D;
 }
}

@-webkit-keyframes anim3 {
 from {
  top: 300px;
  background-color: #3BA9DE;
 }
 to {
  top: 520px;
  left: 310px;
  background-color: #A3E61D;
 }
}


index.html
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <link href="css/style.css" rel="stylesheet" />
  •  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
  • </head>
  • <body>
  •  <div class="main">
  •   <div class="wrapper">
  •    <div id="div1"></div>
  •   </div>
  •   <div class="wrapper">
  •    <div id="div2"></div>
  •   </div>
  •   <div class="wrapper">
  •    <div id="div3"></div>
  •   </div>
  •  </div>
  • <script>
  •  /*JavaScript*/
  •  document.getElementById("div2").style.animationTimingFunction="ease-out";
  •  document.getElementById("div2").style.msAnimationTimingFunction="ease-out";
  •  /*jQuery*/
  •  $(document).ready(function() {
  •   $("#div3").css({ "animation-timing-function": "ease-in-out" });
  •   $("#div3").css({ "-moz-animation-timing-function": "ease-in-out" });
  •   $("#div3").css({ "-o-animation-timing-function": "ease-in-out" });
  •   $("#div3").css({ "-webkit-animation-timing-function": "ease-in-out" });
  •  });
  • </script>
  • </body>
  • </html>
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <link href="css/style.css" rel="stylesheet" />
  •  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
  • </head>
  • <body>
  •  <div class="main">
  •   <div class="wrapper">
  •    <div id="div1"></div>
  •   </div>
  •   <div class="wrapper">
  •    <div id="div2"></div>
  •   </div>
  •   <div class="wrapper">
  •    <div id="div3"></div>
  •   </div>
  •  </div>
  • <script>
  •  /*JavaScript*/
  •  document.getElementById("div2").style.animationTimingFunction="ease-out";
  •  document.getElementById("div2").style.msAnimationTimingFunction="ease-out";
  •  /*jQuery*/
  •  $(document).ready(function() {
  •   $("#div3").css({ "animation-timing-function": "ease-in-out" });
  •   $("#div3").css({ "-moz-animation-timing-function": "ease-in-out" });
  •   $("#div3").css({ "-o-animation-timing-function": "ease-in-out" });
  •   $("#div3").css({ "-webkit-animation-timing-function": "ease-in-out" });
  •  });
  • </script>
  • </body>
  • </html>