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>
相关推荐
BillKu8 分钟前
npm 安装命令中关于 @ 的讲解,如:npm install @vue-office/docx vue-demi
前端·vue.js·npm
yangzhi_emo21 分钟前
ES6笔记4
前端·笔记·es6
萌萌哒草头将军27 分钟前
Node.js v24.8.0 新功能预览!🚀🚀🚀
前端·javascript·node.js
超人不会飛30 分钟前
大模型应用 Vue H5 模板:快速落地流式交互与富文本渲染的开箱方案
前端·vue.js·github
用户4582031531731 分钟前
CSS无需JavaScript的交互效果实现
前端·css
影i33 分钟前
在 Vue + Codemirror 中优雅回显 JSON
前端
奇怪的前端733 分钟前
Alien-Signals 响应式系统
前端·vue.js
你单排吧38 分钟前
Electron打包图标修改失败问题
前端
@AfeiyuO41 分钟前
vue3 实现将页面生成 pdf 导出(html2Canvas + jspdf)
前端·pdf·vue
华仔啊1 小时前
Vue 的 DOM 更新竟然是异步的?90%的人没有搞懂 nextTick
前端·vue.js