通过CSS3的动画知识来完成一个旋转的太极。
任务
1、创建一个div,用CSS控制其大小、边框、位置等,做成一个静态的圆形,一半为红色一半为白色。
2、用div的伪元素位置两个圆环并放置核实位置,使其成为一个太极图案。
3、创建动画。
4、定义动画的重复属性,让其循环播放。

<!DOCTYPE html>
<html>
<head lang="zh-CN">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<title></title>
<style>
/* 外围样式 */
html,
body {
margin: 0;
padding: 0;
height: 100%;
}
/* 主体样式 */
div {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
box-sizing: border-box;
400px;
height: 400px;
margin: auto;
border-bottom: 200px solid red;
border-radius: 50%;
transform-origin: 50% 50%;
animation-name: rotate;
animation-duration: 5s;
animation-timing-function: linear;
/* 补充代码 */
}
</style>
</head>
<body>
<div></div>
</body>
</html>
参考代码:
<!DOCTYPE html>
<html>
<head lang="zh-CN">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<title></title>
<style>
/* 外围样式 */
html,
body {
margin: 0;
padding: 0;
height: 100%;
}
/* 主体样式 */
div {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
box-sizing: border-box;
400px;
height: 400px;
margin: auto;
border-bottom: 200px solid red;
border-radius: 50%;
transform-origin: 50% 50%;
animation-name: rotate;
animation-duration: 5s;
animation-timing-function: linear;
/* 补充代码 */
box-shadow: 0 0 0 1px red,
0 0 20px 5px red;
border-top: 200px solid white;
animation-direction: normal;
animation-iteration-count: infinite;
animation-play-state: running;
}
/* 太极半圆 */
div::after {
100px;
height: 100px;
border: 50px solid red;
position: absolute;
content: '';
display: block;
top: -100px;
left: 0;
border-radius: 50%;
background-color: white;
}
div::before {
100px;
height: 100px;
border: 50px solid white;
position: absolute;
content: '';
display: block;
top: -100px;
right: 0px;
border-radius: 50%;
background-color: red;
}
@keyframes rotate {
from {
transform: rotateZ(0deg);
}
to {
transform: rotateZ(360deg);
}
}
</style>
</head>
<body>
<div></div>
</body>
</html>