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>

相关推荐

最近更新

  1. TCP协议是安全的吗?

    2023-12-08 14:42:03       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2023-12-08 14:42:03       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2023-12-08 14:42:03       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2023-12-08 14:42:03       20 阅读

热门阅读

  1. 云架构的思考3--云上开发

    2023-12-08 14:42:03       37 阅读
  2. Spring Boot 应用安全监控与管理的最佳实践

    2023-12-08 14:42:03       41 阅读
  3. 【盘点世界十大著名黑客攻击事件】

    2023-12-08 14:42:03       32 阅读
  4. Android 开发中 常见的数据结构有哪些?

    2023-12-08 14:42:03       38 阅读
  5. 第6节:Vue3 调用函数

    2023-12-08 14:42:03       45 阅读
  6. spark3.x 读取hudi报错

    2023-12-08 14:42:03       26 阅读