Detailed CSS3animation property (b)

Detailed CSS3animation property (b)


animation-iteration-count


animation-iteration-count property

The number of cycles to retrieve or set the object animation

grammar

animation-iteration-count: infinite | <number>;

Parameter Description

<Number> is a number whose default value is "1"; infinite infinite number of cycles


Programming Exercises

We learned knowledge of animation, then we accomplished together Tai Chi diagram of a rotating bar.


task

  1. Create a div, use CSS to control its size, borders, location, etc., made of a static circle, usually red, usually white
  2. Draw two rings pseudo div element and placing a suitable location makes Tai Chi pattern
  3. Creating animations
  4. Repeat property defines the animation, let loop
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>CSS3animation属性详解(二)</title>
		<style type="text/css">
			div{
				position: absolute;
				top: 0;
				right: 0;
				bottom: 0;
				left: 0;
				box-sizing: border-box;
				width: 400px;
				height: 400px;
				margin: auto;
				border: 1px solid red;
				border-bottom: 200px solid red;
				border-radius: 50%;
				transform-origin: 50% 50%;
				animation-name: rotate;
				animation-duration: 5s;
				animation-timing-function: linear;
				animation-iteration-count: infinite;
			}
			div:before{
				content: "";
				float: left;
				width: 50px;
				height: 50px;
				border: 75px solid red;
				background-color: white;
				margin-top: 100px;
				border-radius: 50%;
			}
			div:after{
				content: "";
				float: right;
				width: 50px;
				height: 50px;
				border: 75px solid white;
				background-color: red;
				margin-top: -200px;
				border-radius: 50%;
			}
			@keyframes rotate{
				from{transform: rotate(0deg);}
				to{transform: rotate(360deg);}
			}
		</style>
	</head>
	<body>
		<div></div>
	</body>
</html>

Published 15 original articles · won praise 16 · views 224

Guess you like

Origin blog.csdn.net/qq_43133192/article/details/104863524