Home > Web Front-end > CSS Tutorial > How to use CSS3 animation properties

How to use CSS3 animation properties

php中世界最好的语言
Release: 2017-11-24 10:36:07
Original
1641 people have browsed it

Today we will tell you how to use Transform animationproperty and its usage techniques. What aspects should be paid attention to when using animation properties? Let me give you a small example below.

Transform Animation Property

The transform property applies a 2D or 3D transformation to an element. This property allows us to rotate, scale, move or tilt the element.

rotate3d(x,y,z,angle) x,y,z attribute 1 rotates around that axis angle deg

@ keyframes name predefined effect

animation attribute is an abbreviated attribute used to set six animation attributes:

case;

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<link href="css/index.css" rel="stylesheet" type="text/css" />
</head>
<style type="text/css">
*{
      margin:0px;
      padding:0px;    
}
img{ display:block;}
.wrap{
      border:1px solid #ff0000;
      width:380px;
      height:565px;
      margin:0 auto;
      position:relative;
      top:50px;   
      -webkit-animation:upDown 2s linear infinite;
}
@-webkit-keyframes upDown{
      0%{-webkit-transform:translateY(0);}     
      50%{-webkit-transform:translateY(20px);}
      100%{-webkit-transform:translateY(0px);}
}
@-webkit-keyframes rota_head{
      0%{-webkit-transform:rotate(0);}    
      50%{-webkit-transform:rotate(-5deg);}
      100%{-webkit-transform:rotate(0);}
}
.head{
      border:1px solid #ff0000;
      position:absolute;
      top:10px;
      left:0;
      z-index:1;   
      -webkit-animation:rota_head 2s linear infinite;
}
@-webkit-keyframes eye_open{
      0%{opacity:1;}
      85%{opacity:1;}
      90%{opacity:0;}     
      100%{opacity:1;}   
}
.eye_open{
      position:absolute;
      top:25px;
      left:40px;
      -webkit-animation:eye_open 2s linear infinite;
}
@-webkit-keyframes eye_close{
      0%{opacity:0;}
      85%{opacity:0;}
      90%{opacity:1;}     
      100%{opacity:0;}   
}
.eye_close{
      position:absolute;
      top:37px;
      left:40px;   
      -webkit-animation:eye_close 2s linear infinite;
 
}
.body{
      position:absolute;top:25px;left:8px;
}
.foot{ position:absolute;left:8px;bottom:0px;}
  </style>
<body>
<div class="wrap">
      <div class="head">
          <img src="imgs/sprite_43.png" alt="">
        <img src="imgs/shape_45.png" alt="" class="eye_open">
        <img src="imgs/shape_46.png" alt="" class="eye_close">
    </div>
    <div class="body">
          <img src="imgs/sprite_40.png">
    </div>
    <div class="foot">
          <img src="imgs/shape_41.png">
    </div>
</div>
</body>
</html>
Copy after login

Css3 animation I believe everyone already knows how to use it. For more exciting information, please pay attention to other related articles on the php Chinese website!

Related reading:

How to use attribute selectors and pseudo-class selectors

How to use the text-shadow font shadow of CSS3

How to use CSS3 box-shadow

The above is the detailed content of How to use CSS3 animation properties. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template