使用clip-path属性和伪元素实现矩形切角

效果图

Snipaste_2020-08-03_16-12-33.png

代码

    <div class="box"></div>

     <style>
        .box {
            width: 200px;
            height: 100px;
            box-shadow: 0 0 20px #0ABBAC inset;
            border: 1px solid #0ABBAC;
            position: relative;
            clip-path: polygon(15px 0, 100% 0, 
                    100% calc(100% - 15px), calc(100% - 15px) 100%,
                    15px 100%,0 15px)
        }

        .box::before {
            content: '';
            width: 0;
            height: 0;
            position: absolute;
            right: 0;
            bottom: 0;
            border-bottom: 15px solid #0ABBAC;
            border-left: 15px solid transparent;
        }

        .box::after {
            content: '';
            width: 0;
            height: 0;
            position: absolute;
            left: 0;
            top: 0;
            width: 0;
            height: 0;
            border-top: 15px solid #0ABBAC;
            border-right: 15px solid transparent;
        }


    </style>

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

友情链接更多精彩内容