CSS 画一个八卦

效果图:

实现原理:

设置高度为宽度的2倍的一个框,利用 border 补全另一半的宽度,设置圆角

用两个 div 设置不同的颜色,定位到圆的上下指定位置。

最后只剩下里面的小圆圈了。设个宽高,圆角即可。

 

CSS

 1         body{
 2             height: 100%;
 3             margin: 0 auto;
 4         }
 5         .bg_box{
 6             width: 100px;
 7             height: 200px;
 8             margin: 200px auto;
 9             background-color: white;
10             border-color: black;
11             border-style: solid;
12             border-width: 2px 2px 2px 100px;
13             border-radius: 100%;
14             position: relative;
15             animation: xuanzhuan 4s linear infinite;
16         }
17         .top-circle{
18             position:absolute;
19             left:-50px;
20             top:0;
21             height:100px;
22             width:100px;
23             text-align:center;
24             line-height:100px;
25             border-radius:100%;
26             background:#000;
27         }
28         .bottom-circle{
29             position:absolute;
30             left:-50%;
31             bottom:0;
32             height:100px;
33             width:100px;
34             text-align:center;
35             line-height:100px;
36             border-radius:100%;
37             background:#fff;
38         }
39         .small-circle{
40             display:inline-block;
41             height:25px;
42             width:25px;
43             border-radius:100%;
44         }
45         .white{
46             background:#fff;
47         }
48         .black{
49             background:#000;
50         }
51         @keyframes xuanzhuan{
52             0%{
53                 transform: rotate(0deg);
54             }
55             100%{
56                 transform: rotate(360deg);
57             }
58         }

 

HTML

    <div class="bg_box">
        <div class="top-circle">
            <span class="small-circle white"></span>
        </div>
        <div class="bottom-circle">
            <span class="small-circle black"></span>
        </div>
    </div>    

 

转载于:https://www.cnblogs.com/wyhlightstar/p/7754496.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值