用HTML+css实现太极八卦图
时间: 2024-03-10 07:50:11 浏览: 180
利用HTML和CSS制作一个八卦图.md
好的,以下是一个用HTML和CSS实现太极八卦图的代码:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>太极八卦图</title>
<style>
#taiji {
width: 200px;
height: 200px;
border-radius: 50%;
background: linear-gradient(90deg, #000000, #ffffff, #000000);
position: relative;
transform: rotate(45deg);
}
#taiji:before {
content: '';
display: block;
width: 100px;
height: 100px;
border-radius: 50%;
background-color: #ffffff;
position: absolute;
top: 0;
left: 50%;
margin-left: -50px;
}
#taiji:after {
content: '';
display: block;
width: 100px;
height: 100px;
border-radius: 50%;
background-color: #000000;
position: absolute;
bottom: 0;
left: 50%;
margin-left: -50px;
}
#taiji .yin {
width: 50px;
height: 50px;
border-radius: 50%;
background-color: #ffffff;
position: absolute;
top: 25px;
left: 50%;
margin-left: -25px;
}
#taiji .yang {
width: 50px;
height: 50px;
border-radius: 50%;
background-color: #000000;
position: absolute;
bottom: 25px;
left: 50%;
margin-left: -25px;
}
#taiji .left {
width: 50px;
height: 50px;
border-radius: 50% 0 0 50%;
background-color: #000000;
position: absolute;
top: 75px;
left: 0;
}
#taiji .right {
width: 50px;
height: 50px;
border-radius: 0 50% 50% 0;
background-color: #ffffff;
position: absolute;
top: 75px;
right: 0;
}
#taiji .left:before {
content: '';
display: block;
width: 25px;
height: 50px;
background-color: #ffffff;
position: absolute;
top: 0;
left: 0;
}
#taiji .right:before {
content: '';
display: block;
width: 25px;
height: 50px;
background-color: #000000;
position: absolute;
top: 0;
right: 0;
}
#taiji .left:after {
content: '';
display: block;
width: 50px;
height: 50px;
background-color: #000000;
position: absolute;
top: 0;
left: 25px;
border-radius: 50%;
transform: rotate(45deg);
}
#taiji .right:after {
content: '';
display: block;
width: 50px;
height: 50px;
background-color: #ffffff;
position: absolute;
top: 0;
right: 25px;
border-radius: 50%;
transform: rotate(45deg);
}
</style>
</head>
<body>
<div id="taiji">
<div class="yin"></div>
<div class="yang"></div>
<div class="left"></div>
<div class="right"></div>
</div>
</body>
</html>
```
这段代码会生成一个200*200大小的太极八卦图,使用了CSS3的渐变、旋转、倾斜等属性来实现。同时,八卦图内部的阴、阳两极和四个小半圆也使用了CSS来绘制。
阅读全文