CSS3 实现太极图案

CSS3实现太极图案html

分析图片组成(以下图所示):git

先给出html代码:github

<div class="box">
        <div class="content">
            <div class="left"></div>
            <div class="right"></div>
            <div class="inner-circle up">
                <div class="sm-circle circle-white"></div>
            </div>
            <div class="inner-circle down">
                <div class="sm-circle circle-black"></div>
            </div>
        </div>
    </div>
View Code

 

步骤一:web

先把紫色框出来的两个div修改其样式,使其分别成两个半圆,一黑一白。ide

.left{
    position: absolute;
    width: 50%;
    top: 0;
    left:0;
    height: 100%;
    background-color: #000000;
    border-radius: 100% 0 0 100% / 50% 0 0 50%;
}
.right{
    position: absolute;
    width: 50%;
    top: 0;
    right: 0;;
    height: 100%;
    background-color: #FFFFFF;
    border-radius: 0 100% 100% 0 / 0 50% 50% 0;
}
View Code

步骤二:把外面的红色框添加样式,使其变成圆,一黑一白动画

.inner-circle{
    position: absolute;
    width: 50%;
    height: 50%;
    left: 25%;
    border-radius:50% ;
}
.up{ 
    top: 0;
    background-color: #000000;
}
.down{
    bottom: 0;
    background-color: #FFFFFF;
}
View Code

第三步:给最里面的红色框添加样式,使其变成圆,一黑一白spa

.sm-circle{
    position: absolute;
    width: 25%;
    height: 25%;
    top: 37.5%;
    left: 37.5%;
    border-radius: 50%;
}
.circle-white{
    background-color: #FFFFFF;
}
.circle-black{
    background-color: #000;
}
View Code

最后:给太极图案最外层的div添加动画,使其动起来3d

设置动画code

@keyframes Rotate {
    0%{
        -webkit-transform: rotate(0deg);
        -moz-transform: rotate(0deg);
        -ms-transform: rotate(0deg);
        transform: rotate(0deg);
    }
    100%{
        -webkit-transform: rotate(360deg);
        -moz-transform: rotate(360deg);
        -ms-transform: rotate(360deg);
        transform: rotate(360deg);
    }
}
View Code

给div绑定动画orm

.content{
    margin: 0 auto;
    position: relative;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background-color: #FFFFFF;
    border: 1px solid #aaa;
    animation: Rotate 6s linear infinite;
}
View Code

好了,旋转的太极就画好了,是否是很简单呀

运行效果,请点击:http://hjjia.github.io/h5translate3d/taiji/

相关文章
相关标签/搜索