太极图有没有更简洁的代码
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>2-5</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: 2s;
animation-timing-function: linear;
animation-iteration-count: infinite;
/*此处写代码*/
} div::after{
content: ""; display: block;
position: absolute;
top:100px; left: -1px;
box-sizing: border-box;
width: 199px; height: 199px;
border-top: 101px solid red;
border-radius: 50%;
} div::before{
content: ""; display: block;
position: absolute;
top:100px; left: 199px;
box-sizing: border-box;
width: 199px; height: 199px;
border-bottom: 101px solid white;
border-radius: 50%;
} div > span{
position: absolute;
width: 40px; height: 40px;
display: block;
border-radius: 50%;
} div > span:first-of-type{
z-index: 10000;
left: 70px; top: 150px;
background: white;
}
div > span:last-of-type{
z-index: 10000;
left: 270px; top: 150px;
background: red;
} @keyframes rotate{
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
} </style>
</head>
<body>
<div>
<span></span>
<span></span>
</div>
</body>
</html>
正在回答
你写的已经很好了,继续加油!
- 参与学习 1887 人
- 提交作业 4643 份
- 解答问题 5760 个
有HTML和CSS基础,却不知道如何进阶?本路径带你通过系统学习,完成从“会做网页”到“做出好的动态网页”的蜕变,迈出成为前端工程师的第一步。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星