CSS实现图片缺角效果

效果:

源码:

html 复制代码
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>123</title>
    <style>
        body {
            margin: 0;
            padding: 0;
            background: #f9f9f9;
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100vh;
        }

        .row {
            display: flex;
            padding: 30px;
            gap: 30px;
            flex-wrap: wrap;
            background: inherit;
        }

        .box {
            position: relative;
            width: 500px;
            height: 250px;
            border-radius: 20px;
            background-color: inherit;
        }

        .btn {
            display: inline-flex;
            padding: 12px 20px;
            justify-content: center;
            align-items: center;
            color: white;
            text-decoration: none;
            background-color: #000521;
            border-radius: 80px;
        }

        .btn-decor-wrap {
            position: absolute;
            left: 0;
            bottom: 0;
            display: inline-block;
            padding: 24px 24px 0 0;
            margin: 24px 24px 0 0;
            border-top-right-radius: 45px;
            background-color: inherit;
        }

        .btn-decor-wrap:after,
        .btn-decor-wrap:before {
            z-index: 0;
            position: absolute;
            display: block;
            width: 24px;
            height: 24px;
            content: '';
            clip-path: polygon(0.082%0%, 0%0%, 0%100%, 100%100%, 100%99.918%, 100%99.918%, 84.085%98.066%, 68.994%93.913%, 54.912%87.642%, 42.022%79.44%, 30.51%69.49%, 20.56%57.978%, 12.358%45.088%, 6.088%31.006%, 1.934%15.915%, 0.082%0%);
            background-color: inherit;
            overflow: hidden;
        }

        .btn-decor-wrap:before {
            top: -24px;
            left: 0;
        }

        .btn-decor-wrap:after {
            right: -24px;
            bottom: 0;
        }
    </style>
</head>

<body>
    <div class="row">
        <div class="box" style="background-image: url('https://img-home.csdnimg.cn/images/20250224104257.png');background-size: cover;background-position: center;">
            <span class="btn-decor-wrap">
                <a href="#" class="btn">了解更多</a>
            </span>
        </div>
    </div>
</body>

</html>
相关推荐
Mintopia6 分钟前
计算机图形学环境贴图(Environment Mapping)教学指南
前端·javascript·计算机图形学
码农之王8 分钟前
(二)TypeScript前置编译配置
前端·后端·typescript
spmcor9 分钟前
css 之 Flexbox 的一生
前端·css
Mintopia12 分钟前
Three.js 高级纹理(Advanced Textures):超越基础,打造沉浸式 3D 世界
前端·javascript·three.js
玄玄子13 分钟前
JS Promise
前端·javascript·程序员
Thanks_ks21 分钟前
探索现代 Web 开发:从 HTML5 到 Vue.js 的全栈之旅
javascript·vue.js·css3·html5·前端开发·web 开发·全栈实战
GIS之路24 分钟前
OpenLayers 获取地图状态
前端·javascript·html
FogLetter40 分钟前
深入理解Flex布局:grow、shrink和basis的计算艺术
前端·css
remember_me41 分钟前
前端打印实现-全网最简单实现方法
前端·javascript·react.js
前端小巷子44 分钟前
IndexedDB:浏览器端的强大数据库
前端·javascript·面试