css如何写出带边框的六边形

效果图展示


image.png

html代码

<div class="logic_type">
            <div class="logic_type-wrap clearfix logic-with">
                <div class="logic_type-border-left pull-left">
                    <div class="logic_type-left"></div>
                </div>
                <div class="logic_type-with pull-left">
                    <input type="radio" value="AND">
                    <label for="AND">与</label>
                </div>
                <div class="logic_type-border-right pull-left">
                    <div class="logic_type-right"></div>
                </div>
            </div>
            <div class="logic_type-wrap clearfix">
                <div class="logic_type-border-left pull-left">
                    <div class="logic_type-left"></div>
                </div>
                <div class="logic_type-or pull-left">
                    <input type="radio" value="OR">
                    <label for="OR" class="logic_type-label">或</label>
                </div>
                <div class="logic_type-border-right pull-left">
                    <div class="logic_type-right"></div>
                </div>
            </div>
        </div>

css样式
body {
background: #362e40;
}

        * {
            box-sizing: border-box;
        }
        
        .clearfix:before,
        .clearfix:after {
            display: table;
            content: "";
        }
        
        .clearfix:after {
            clear: both;
        }
        
        .pull-left {
            float: left;
        }
        
        .logic_type-wrap {
            display: inline-block;
            cursor: pointer;
            position: relative;
            margin-right: 2px;
        }
        
        .logic_type-wrap input {
            display: inline-block;
            position: absolute;
            top: -4px;
            left: 0px;
            opacity: 0;
            width: 30px;
            height: 24px;
            z-index: 2;
            cursor: pointer;
        }
        
        .logic_type-with {
            width: 14px;
            height: 24px;
            color: #fff;
            font-size: 14px;
            background: #362e40;
            border-top: 1px solid #d7b7ff;
            border-bottom: 1px solid #d7b7ff;
        }
        
        .logic_type-or {
            width: 14px;
            height: 24px;
            font-size: 14px;
            color: #fff;
            background: #362e40;
            border-top: 1px solid #d7b7ff;
            border-bottom: 1px solid #d7b7ff;
        }
        
        .logic_type-border-left {
            position: relative;
            content: '';
            width: 0px;
            height: 0px;
            border-top: 12px solid transparent;
            border-bottom: 12px solid transparent;
            border-right: 8px solid #d7b7ff;
        }
        
        .logic_type-left {
            position: absolute;
            content: '';
            width: 0px;
            height: 0px;
            border-top: 11px solid transparent;
            border-bottom: 11px solid transparent;
            border-right: 7px solid #362e40;
            top: -11px;
            left: 1px;
        }
        
        .logic_type-border-right {
            position: relative;
            content: '';
            width: 0px;
            height: 0px;
            border-top: 12px solid transparent;
            border-bottom: 12px solid transparent;
            border-left: 8px solid #d7b7ff;
        }
        
        .logic_type-right {
            position: absolute;
            content: '';
            width: 0px;
            height: 0px;
            border-top: 11px solid transparent;
            border-bottom: 11px solid transparent;
            border-left: 7px solid #362e40;
            top: -11px;
            left: -8px;
        }
        
        .logic-with.logic_type-wrap .logic_type-with {
            color: #f9bb26;
            border-top: 1px solid #f9bb26;
            border-bottom: 1px solid #f9bb26;
        }
        
        .logic-with.logic_type-wrap .logic_type-border-left {
            border-right: 8px solid #f9bb26;
        }
        
        .logic-with.logic_type-wrap .logic_type-border-right {
            border-left: 8px solid #f9bb26;
        }
        
        .logic_or.logic_type-wrap .logic_type-or {
            color: #f9bb26;
            border-top: 1px solid #f9bb26;
            border-bottom: 1px solid #f9bb26;
        }
        
        .logic_or.logic_type-wrap .logic_type-border-left {
            border-right: 8px solid #f9bb26;
        }
        
        .logic_or.logic_type-wrap .logic_type-border-right {
            border-left: 8px solid #f9bb26;
        }

这样就可以写出带边框的六边形,我这边主要是radio可以进行选择的需求
有哪些不正确的地方,欢迎大家指出,谢谢

最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • FreeCodeCamp - HTML5 and CSS 发现原来在另外一台电脑学 FreeCodeCamp 的时...
    付林恒阅读 9,713评论 2赞 17
  • HTML 5 HTML5概述 因特网上的信息是以网页的形式展示给用户的,因此网页是网络信息传递的载体。网页文件是用...
    阿啊阿吖丁阅读 5,238评论 0赞 0
  • 问答题47 /72 常见浏览器兼容性问题与解决方案? 参考答案 (1)浏览器兼容问题一:不同浏览器的标签默认的外补...
    _Yfling阅读 14,424评论 1赞 92
  • 新的工作 穆南来H市已有半年了。因为走的匆忙,确切的说,是逃的匆忙,没有带毕业证。这小小一张纸...
    岳柠檬阅读 224评论 0赞 1
  • 蓦然回首, 多了些期望。 没有灯火阑珊, 只求小桥流水, 花布满园。 或是都为憧憬, 到最后, 还是会有一人。
    囚青鸟阅读 197评论 0赞 1

友情链接更多精彩内容