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>
相关推荐
❆VE❆5 分钟前
vue3: directive自定义指令防止重复点击
前端·javascript·vue.js·自定义指令·directive
布兰妮甜11 分钟前
Fetch API 与 XMLHttpRequest:深入剖析异步请求的利器
前端·javascript·xmlhttprequest·fetch api
巴巴博一1 小时前
vue-i18n国际化插件安装教程(Vue3篇)
前端·javascript·vue.js·typescript
Merlyn102 小时前
npm : 无法加载文件 E:\ProgramFiles\Nodejs\npm.ps1,因为在此系统上禁止运行脚本。
前端·npm·node.js
一个打工仔的笔记2 小时前
npm i 失败权限问题
前端·npm·node.js
heroboyluck2 小时前
rust 前端npm依赖工具rsup升级日志
前端·rust·npm
咔咔库奇2 小时前
【react】进阶教程02
前端·react.js·前端框架
七灵微2 小时前
【前端】react大全一本通
前端·react.js·前端框架
初遇你时动了情2 小时前
react使用react-quill 富文本插件、加入handlers富文本不显示解决办法
前端·javascript·react.js