css实现正六边形嵌套圆心

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

  1. 使用::before::after伪元素创建正六边形。
  2. 设置正六边形的背景色。
  3. 使用border-radius属性使正六边形的内角为60度。
  4. 在正六边形内部创建圆形,并设置其位置、大小和背景色。
  5. 使用border-radius属性使圆形的内角为50%,使其呈现圆形效果。
html 复制代码
<!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>
相关推荐
dualven_in_csdn30 分钟前
搞了两天的win7批处理脚本问题
java·linux·前端
你的人类朋友1 小时前
✍️【Node.js程序员】的数据库【索引优化】指南
前端·javascript·后端
小超爱编程2 小时前
纯前端做图片压缩
开发语言·前端·javascript
应巅2 小时前
echarts 数据大屏(无UI设计 极简洁版)
前端·ui·echarts
Jimmy3 小时前
CSS 实现描边文字效果
前端·css·html
islandzzzz3 小时前
HMTL+CSS+JS-新手小白循序渐进案例入门
前端·javascript·css·html
Senar3 小时前
网页中如何判断用户是否处于闲置状态
前端·javascript
很甜的西瓜3 小时前
typescript软渲染实现类似canvas的2d矢量图形引擎
前端·javascript·typescript·图形渲染·canvas
Allen Bright4 小时前
【CSS-9】深入理解CSS字体图标:原理、优势与最佳实践
前端·css
阿芯爱编程5 小时前
最长和谐子序列,滑动窗口
前端·javascript·面试