css3绘制八卦图及动画效果

原理很简单,就是外面加个盒子box。作为旋转动画的box,然后里面分别利用两个div使用css3的 border-radius绘制半圆,分别定位在上下中间对齐两个位置,里面在放两个小的原点水平和垂直方向对齐即可实现。然后在使用Css3的animation属性制作动画。效果如下图。
这里写图片描述

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>css3绘制八卦图及动画效果</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }
        
        .box {
            margin: 100px auto;
            width: 400px;
			height:400px;
			border-radius:200px;
			box-shadow:0 0 10px #999;
			position:relative;
			animation:circleRotate 3s linear 2s infinite;
        }
		.semi-circle{
			height:400px;
			width:200px;
		}
        .box .left{
			background:#000;
			border-top-left-radius:200px;
			border-bottom-left-radius:200px;
		}
		
		.box .right{
			background:#fff;
			border-top-left-radius:200px;
			border-bottom-left-radius:200px;
		}
		.box .top-circle{
			position:absolute;
			left:100px;
			top:0;
			height:200px;
			width:200px;
			text-align:center;
			line-height:200px;
			border-radius:100px;
			background:#000;
		}
		.box .bottom-circle{
			position:absolute;
			left:100px;
			bottom:0;
			height:200px;
			width:200px;
			text-align:center;
			line-height:200px;
			border-radius:100px;
			background:#fff;
		}
		.box .small-circle{
			display:inline-block;
			height:40px;
			width:40px;
			border-radius:20px;
			background:red;
		}
		.box .white{background:#fff;}
		.box .black{background:#000;}
		@keyframes circleRotate{
			%0{
				transform:rotate(0deg);
			}
			100%{
				transform:rotate(360deg);
			}
		}
    </style>
</head>

<body>
    <div class="box">
		<div class="semi-circle left"></div>
		<div class="semi-circle right"></div>
		<div class="top-circle">
			<span class="small-circle white"></span>
		</div>
		<div class="bottom-circle">
			<span class="small-circle black"></span>
		</div>
    </div>
</body>

</html>
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值