用html和css纯代码制作会旋转的太极图(详细讲解)点赞加关注,经典案例持续更新~

效果

会旋转的太极图

先说一下实现思路,将盒子设置很粗的边框,再将盒子设置成圆形,最后将需要的盒子组合在一起形成的太极图。

第一步

一个大盒子里面放俩个小盒子

 <div>
        <section class="laft"></section>
        <section class="right"></section>
 </div>

给大盒子设置css样式

div{
            width: 200px;
            height: 100px;
            border: 1px solid black;
            border-radius: 50%;
            border-bottom-width: 100px;
            margin: 200px auto;
}

 效果

 第二步

设置左边一个小盒子为圆形加粗边框,再移动小盒子到合适的位置,这里为了便于区分,设置颜色为红色,后续再做修改

   .laft{
            border: 40px solid black;
            border-radius: 50%;
            background-color: red;
            margin-top: 50px;
}

效果

右边同理制作出一个蓝色的盒子放到合适的位置,同样为了便于区分设置颜色为蓝色

 .right {
            width: 20px;
            height: 20px;
            border: 40px solid white;
            border-radius: 50%;
            margin-left: 100px;
            margin-top: -100px;
}

效果

第三步 

再改下小盒子背景色和小盒子边框颜色,太极图就完成了

          div {
            width: 200px;
            height: 100px;
            border: 1px solid black;
            border-radius: 50%;
            margin: 200px auto;
            border-bottom-width: 100px;
      }

         .laft {
            width: 20px;
            height: 20px;
            border: 40px solid black;
            border-radius: 50%;
            margin-top: 50px;
            background-color: white;
      }

        .right {
            width: 20px;
            height: 20px;
            border: 40px solid white;
            border-radius: 50%;
            margin-left: 100px;
            margin-top: -100px;
            background-color: black;
        }

效果

 

至此太极图已经完成,如果想要让太极图转起来,设置动画即可,全部的css代码如下

 div {
            width: 200px;
            height: 100px;
            border: 1px solid black;
            border-radius: 50%;
            margin: 200px auto;
            border-bottom-width: 100px;
            /* 关键帧名称 */
            animation-name: taiji;
            /* 动画完成一个周期所需时常设为1秒 */
            animation-duration: 1s;
            /* 动画播放周期设为无限次 */
            animation-iteration-count: infinite;
            /* 动画完成一个周期的速度曲线设置为匀速 */
            animation-timing-function: linear;
        }

        .laft {
            width: 20px;
            height: 20px;
            border: 40px solid black;
            border-radius: 50%;
            margin-top: 50px;
            background-color: white;
        }

        .right {
            width: 20px;
            height: 20px;
            border: 40px solid white;
            border-radius: 50%;
            margin-left: 100px;
            margin-top: -100px;
            background-color: black;
        }

        @keyframes taiji {
            from {
                rotate: 0deg;
            }

            to {
                rotate: 360deg;
            }
        }

  • 4
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

十七同志

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值