今天用Html制作一个会旋转的太极页面
我是一个萌新,有众多不足的地方请大佬多多指教,不喜勿喷
制作后的效果(有改动,手机也可以打开) https://survivor15.github.io/bagua01/
话不多说直接上代码
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>我的第一个页面</title>
<style>
body{
background: #eee;
}
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
@keyframes zhuan{
from{
transform: rotate(0deg);
}
to{
transform: rotate(360deg);
}
}
#八卦{
width: 400px;
height: 400px;
border-radius: 50%;
position: relative;
overflow: hidden;
animation: zhuan 10s infinite linear ;
box-shadow: 0px 0px 5px 3px rgba(0,0,0,0.75);
}
@media(max-width: 500px) {
#八卦{
width: 200px;
height: 200px;
}
}
#八卦>div:first-child{
width: 50%;
height: 100%;
position: absolute;
left: 0;
background: black;
}
#八卦>div:nth-child(2){
width: 50%;
height: 100%;
position: absolute;
right: 0;
background: white;
}
#八卦>div:nth-child(3){
position: absolute;
width: 200px;
height: 200px;
left: 50%;
margin-left: -100px;
border-radius: 50%;
background: black;
}
@media(max-width: 500px){
#八卦>div:nth-child(3){
width: 100px;
height: 100px;
margin-left: -50px;
}
}
#八卦>div:nth-child(4){
position: absolute;
width: 200px;
height: 200px;
left: 50%;
bottom: 0;
margin-left: -100px;
border-radius: 50%;
background: white;
}
@media(max-width: 500px){
#八卦>div:nth-child(4){
width: 100px;
height: 100px;
margin-left: -50px;
}
}
#八卦>div:nth-child(5){
position: absolute;
width: 50px;
height: 50px;
left: 50%;
top: 75px;
margin-left: -25px;
border-radius: 50%;
background: white;
}
@media(max-width: 500px){
#八卦>div:nth-child(5){
width: 25px;
height: 25px;
top: 37.5px;
margin-left: -12.5px;
}
}
#八卦>div:nth-child(6){
position: absolute;
width: 50px;
height: 50px;
left: 50%;
bottom: 75px;
margin-left: -25px;
border-radius: 50%;
background: black;
}
@media(max-width: 500px){
#八卦>div:nth-child(6){
width: 25px;
height: 25px;
bottom: 37.5px;
margin-left: -12.5px;
}
}
#八卦-wrapper{
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
#八卦-描述{
margin-top: 1em;
}
</style>
</head>
<body>
<div id="八卦-wrapper">
<div id="八卦">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
<div id="八卦-描述">
道可道,非常道
</div>
</div>
</body>
</html>
——————————————————————————————
这里代表语言是中文的意思,lang="en"代表英文
——————————————————————————————
这是八卦最外面的圆,这里的50%可以是200px (大于200px也是一个圆)
英文radius的意思是半径
——————————————————————————————
意思是选中“八卦”元素中的第一个div
——————————————————————————————
意思是选中“八卦”元素中的第二个div,以此类推
——————————————————————————————
添加一个CSS3的一个属性 animation 动画的名字叫做zhuan,时间是10s一圈
infiniite是一直循环转的意思,linear是线性的转的意思(即有规律的旋转)
——————————————————————————————
声明一个动画叫zhuan,一开始转0°最后转360°
——————————————————————————————
给八卦图加阴影
——————————————————————————————
100vh——>(vh:viewpoint(用户可以看到的范围)height)
——————————————————————————————
前三行让八卦图居中,最后一行是让div竖着排列
——————————————————————————————
手机
@mediia(媒体查询)
这代码的意思是:当你的页面小于等于500px的时候,我额外的添加一个属性