用HTML5制作一个太极页面

今天用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的时候,我额外的添加一个属性

要记得差不多就这些啦,感谢看到这里的伙伴们❤

有什么不妥的地方欢迎留言评论❤

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
好的,以下是一个简单的HTML代码,用来绘制太极八卦图: ```html <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>太极八卦图</title> </head> <body> <div style="width: 200px; height: 200px; border-radius: 50%; background-color: black; position: relative;"> <div style="width: 100px; height: 100px; border-radius: 50%; background-color: white; position: absolute; top: 0; left: 50%; margin-left: -50px;"></div> <div style="width: 100px; height: 100px; border-radius: 50%; background-color: black; position: absolute; bottom: 0; left: 50%; margin-left: -50px;"></div> <div style="width: 50px; height: 50px; border-radius: 50%; background-color: white; position: absolute; top: 25px; left: 50%; margin-left: -25px;"></div> <div style="width: 50px; height: 50px; border-radius: 50%; background-color: black; position: absolute; bottom: 25px; left: 50%; margin-left: -25px;"></div> <div style="width: 50px; height: 50px; border-radius: 50%; background-color: black; position: absolute; top: 75px; left: 0;"></div> <div style="width: 50px; height: 50px; border-radius: 50%; background-color: white; position: absolute; top: 75px; right: 0;"></div> <div style="width: 50px; height: 50px; border-radius: 50%; background-color: white; position: absolute; bottom: 75px; left: 0;"></div> <div style="width: 50px; height: 50px; border-radius: 50%; background-color: black; position: absolute; bottom: 75px; right: 0;"></div> </div> </body> </html> ``` 这段代码会生成一个200*200大小的黑色圆形,内部有一个白色圆和一个黑色圆,分别占据圆的上下两个半部分。同时,圆内四个角落处分别有一个黑色/白色的半圆,构成了八卦图的形状。
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值