CSS实现太极图

具体思路:一个西瓜分两半 左边一半右边一半 上面一半下面一半

 代码:

<style>
        .a {
            /* 一整个大圆(大西瓜) */
            position: relative;
            width: 500px;
            height: 500px;
            border: 1px solid #000;
            border-radius: 50%;
            overflow: hidden;
        }
        /* 分出左圆和右圆 大西瓜分成两个*/
        .a::before,.a::after {
            content: '';
            float: left;
            width: 250px;
            height: 500px;
        }
        .a::before {
            background-color: #fff;
        }
        .a::after {
            background-color: #000;
        }
        /* 太极的圆 上下两大圆  */
        .b,.c {
            position: absolute;
            left: 50%;
            width: 250px;
            height: 250px;
            margin-left: -125px;
            border-radius: 50%;
        }
        .b {
            top: 0;
            background-color: #fff;
        }
        .c {
            bottom: 0;
            background-color: #000;
        }
        /* 大圆内的小圆定位过去 */
        .b::before,.c::before {
            content: '';
            width: 50px;
            height: 50px;
            position: absolute;
            top: 50%;
            margin-top: -25px;
            left: 50%;
            margin-left: -25px;
            border-radius: 50%;
        }
        .b::before{
            background-color:black;
        }
        .c::before{
            background-color:white;
        }
    </style>
</head>
<body>
    <div class="a">
        <div class="b"></div>
        <div class="c"></div>
    </div>
</body>

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值