css实现六角星

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .six-star{
            width: 0;
            height: 0;
            border-bottom: 100px solid red;
            border-left: 50px solid transparent;
            border-right: 50px solid transparent;
            position: relative;
        }
        .six-star:after{
            content: '';
            width: 0;
            height: 0;
            position: absolute;
            left: -50px;
            top: 25px;
            border-top: 100px solid red;
            border-left: 50px solid transparent;
            border-right: 50px solid transparent;
        }
    </style>
</head>
<body>
    <div class="six-star">
    </div>
</body>
</html>

在这里插入图片描述

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
好的,我分别为您回答如下: 1. HTML CSS 画五角 HTML结构: ```html <div class="star"></div> ``` CSS样式: ```css .star { width: 0; height: 0; border-right: 50px solid transparent; border-bottom: 35px solid #f1c40f; border-left: 50px solid transparent; position: relative; top: -10px; } .star:before { content: ""; width: 0; height: 0; border-right: 50px solid transparent; border-bottom: 35px solid #f1c40f; border-left: 50px solid transparent; position: absolute; top: -25px; left: -50px; transform: rotate(35deg); } .star:after { content: ""; width: 0; height: 0; border-right: 50px solid transparent; border-bottom: 35px solid #f1c40f; border-left: 50px solid transparent; position: absolute; top: -25px; left: 0; transform: rotate(-35deg); } ``` 2. CSS 画梯形 HTML结构: ```html <div class="trapezoid"></div> ``` CSS样式: ```css .trapezoid { border-bottom: 100px solid #f1c40f; border-left: 50px solid transparent; border-right: 50px solid transparent; height: 0; width: 100px; } ``` 3. CSS六角 HTML结构: ```html <div class="hexastar"></div> ``` CSS样式: ```css .hexastar { width: 0; height: 0; border-bottom: 50px solid #f1c40f; border-left: 29px solid transparent; border-right: 29px solid transparent; position: relative; } .hexastar:before { content: ""; width: 0; height: 0; border-top: 50px solid #f1c40f; border-left: 29px solid transparent; border-right: 29px solid transparent; position: absolute; top: -50px; left: -29px; } ``` 4. CSS 画六边形 HTML结构: ```html <div class="hexagon"></div> ``` CSS样式: ```css .hexagon { width: 100px; height: 55px; background-color: #f1c40f; position: relative; } .hexagon:before, .hexagon:after { content: ""; position: absolute; z-index: 1; width: 0; border-left: 50px solid transparent; border-right: 50px solid transparent; } .hexagon:before { bottom: 100%; border-bottom: 28px solid #f1c40f; } .hexagon:after { top: 100%; width: 0; border-top: 28px solid #f1c40f; } ```

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值