css实现正六边形嵌套圆心

要实现一个正六边形嵌套圆心,可以使用CSS的::before::after伪元素以及border-radius属性。以下是具体的解析和代码:

  1. 使用::before::after伪元素创建正六边形。
  2. 设置正六边形的背景色。
  3. 使用border-radius属性使正六边形的内角为60度。
  4. 在正六边形内部创建圆形,并设置其位置、大小和背景色。
  5. 使用border-radius属性使圆形的内角为50%,使其呈现圆形效果。

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>正六边形中间圆形</title>
    <style>
        .hexagon {
            position: relative;
            width: 200px;
            height: 100px;
            background-color: #F99B68;
            margin: 50px auto;
        }

        .hexagon::before,
        .hexagon::after {
            content: "";
            position: absolute;
            width: 0;
            height: 0;
            border-left: 100px solid transparent;
            border-right: 100px solid transparent;
        }

        .hexagon::before {
            bottom: 100%;
            border-bottom: 50px solid #F99B68;
            border-top: 50px solid #F99B68;
        }

        .hexagon::after {
            top: 100%;
            border-top: 50px solid #F99B68;
            border-bottom: 50px solid white;
        }

        .circle {
            position: absolute;
            top: 0px;
            left: 26%;
            width: 100px;
            height: 100px;
            background-color: white;
            border-radius: 50%;
        }
        .point {
            position: absolute;
            top: 25px;
            left: 25%;
            width: 50px;
            height: 50px;
            background-color: #F99B68;
            border-radius: 50%;
        }
    </style>
</head>
<body>
    <div class="hexagon">
        <div class="circle">
            <div class="point"></div>
        </div>
    </div>
</body>
</html>

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值