完整代码(可运行)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box {
position: relative;
width: 300px;
height: 300px;
border-radius: 50%;
background-color: orange;
overflow: hidden;
animation: rotate 2s linear infinite;
}
.box>div {
position: absolute;
top: 0;
right: 0;
width: 50%;
height: 50%;
transform-origin: 0 100%;
}
.box1 {
transform: rotate(0deg);
background-color: lavenderblush;
}
.box2 {
transform: rotate(180deg);
background-color: lightgreen;
}
@keyframes rotate {
0% {
}
100% {
transform: rotate(360deg);
}
}
</style>
</head>
<body>
<div class="box">
<div class="box1"></div>
<div class="box2"></div>
</div>
</body>
</html>
关键代码
.box{
animation: rotate 2s linear infinite;
}
@keyframes rotate {
0% {
}
100% {
transform: rotate(360deg);
}
}