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>
相关推荐
倚栏听风雨11 分钟前
详解 TypeScript 中,async 和 await
前端
小皮虾19 分钟前
告别服务器!小程序纯前端“图片转 PDF”工具,隐私安全又高效
前端·javascript·微信小程序
ohyeah20 分钟前
我的变量去哪了?JS 作用域入门指南
前端·javascript
今日无bug22 分钟前
🥁 用 HTML5 打造你的第一个“敲击乐” Web 应用
html
灼华_22 分钟前
Vue 3 + Vite + Router + Pinia + Element Plus + Monorepo + qiankun 构建企业级中后台前端框架
前端
倚栏听风雨24 分钟前
TypeScript 中,Promise
前端
影i42 分钟前
Vue 3 踩坑实录:如何优雅地把“上古”第三方插件关进 Iframe 小黑屋
前端
小明记账簿_微信小程序42 分钟前
vue项目中使用echarts做词云图
前端
浪浪山_大橙子44 分钟前
Trae SOLO 生成 TensorFlow.js 手势抓取物品太牛了 程序员可以退下了
前端·javascript
出征1 小时前
Pnpm的进化进程
前端