Home  >  Article  >  Web Front-end  >  How to achieve rotation and scaling animation effect in css3

How to achieve rotation and scaling animation effect in css3

WBOY
WBOYOriginal
2021-12-16 11:45:542459browse

Method: 1. Use the "element {animation:name time}" statement to bind the rotation and scaling animation to the element; 2. Use "@keyframes name {100%{transform:rotate(rotation angle) scale(scale) Proportion);}}" statement to achieve the rotation and scaling animation effect.

How to achieve rotation and scaling animation effect in css3

The operating environment of this tutorial: Windows 10 system, CSS3&&HTML5 version, Dell G3 computer.

How to achieve rotation and scaling animation effects in css3

In css, you can use the animation attribute to bind rotation and scaling animations to elements.

Use the @keyframes rule to set the animation action keyframes of the element, use the transform attribute with the rotate() function to set the element rotation action, and use the transform attribute with the scale() function to set the element scaling action.

The example is as follows:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
.div1{
  width:100px;
  height:100px;
  background:pink;
  margin:0 auto;
animation:fadenum 5s;
}
@keyframes fadenum{
  100%{transform:rotate(180deg) scale(0.5,0.5);}
}
</style>
</head>
<body>
<div class="div1">这是一个旋转缩放的效果</div>
</body>
</html>

Output result:

How to achieve rotation and scaling animation effect in css3

(Learning video sharing: css video tutorial)

The above is the detailed content of How to achieve rotation and scaling animation effect in css3. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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