【React】Ant Design 5.x 实现tabs圆角及反圆角效果

需要实现的效果


实现思路

利用tab页的before和after属性,添加tab页前后的圆弧属性,同时使用tab页的shadow阴影填充右下角的圆弧空缺部分。

复制代码
            <Tabs
                onChange={onChange}
                type="card"
                items={getTabItems()}
            />

.ant-tabs-nav{
        margin: 0;

        .ant-tabs-nav-list{
            display: flex;
            position: relative;
            z-index: 2;
            width: 100%;
            background: #E1E8F2;
            border-radius: 24px 24px 0 0;
            overflow: hidden; // 重点
            user-select: none;
        }

        .ant-tabs-tab{
            flex: 1;
            position: relative;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 66px;
            padding: 18px 0;
            margin: 0;
            border: none;
            font-weight: 500;
            font-size: 22px;
            color: #606266;
            line-height: 30px;
            text-align: left;
            font-style: normal;
            border-radius: 24px 24px 0 0 !important;
            background: #E1E8F2;
            transition: none;
            user-select: none;

            &::before{
                content: '';
                position: absolute;
                left: 10px;
                bottom: 0;
                width: 32px;
                height: 66px;
                background: #E1E8F2;
                border-bottom-left-radius: 24px;
                transform: skewX(15deg); // 重点
                z-index: 4; 
            }
            &::after{
                z-index: 4;
                content: '';
                position: absolute;
                right: 10px;
                bottom: 0;
                width: 32px;
                height: 66px;
                background: #E1E8F2;
                border-bottom-right-radius: 24px;
                transform: skewX(-15deg); // 重点
            }
        }
        .ant-tabs-tab-active{
            opacity: 1;
            z-index: 3; 
            background: #ffffff;
            border-radius: 24px 24px 0 0 !important;
            box-shadow: 48px 42px 0 #ffffff, -48px 42px 0 #ffffff; // 重点
            user-select: none;

            &::before{
                content: '';
                position: absolute;
                left: -12px;
                bottom: 0;
                width: 24px;
                height: 66px;
                border-top-left-radius: 24px;
                background-color: #ffffff;
                transform: skewX(-15deg); // 重点
            }
            &::after{
                content: '';
                position: absolute;
                right: -12px;
                bottom: 0;
                width: 24px;
                height: 66px;
                border-top-right-radius: 24px;
                background-color: #ffffff;
                transform: skewX(15deg); // 重点
            }
        }
    }
相关推荐
怕浪猫1 分钟前
React从入门到出门 第五章 React Router 配置与原理初探
前端·javascript·react.js
jinmo_C++1 分钟前
从零开始学前端 · HTML 基础篇(一):认识 HTML 与页面结构
前端·html·状态模式
哈__6 分钟前
React Native 鸿蒙跨平台开发:LayoutAnimation 实现鸿蒙端表单元素的动态添加动画
react native·react.js·harmonyos
鹏多多7 分钟前
前端2025年终总结:借着AI做大做强再创辉煌
前端·javascript
哈__11 分钟前
React Native 鸿蒙跨平台开发:Vibration 实现鸿蒙端设备的震动反馈
javascript·react native·react.js
小Tomkk16 分钟前
⭐️ StarRocks Web 使用介绍与实战指南
前端·ffmpeg
不一样的少年_20 分钟前
产品催: 1 天优化 Vue 官网 SEO?我用这个插件半天搞定(不重构 Nuxt)
前端·javascript·vue.js
-dcr21 分钟前
50.智能体
前端·javascript·人工智能·ai·easyui
行者9631 分钟前
Flutter跨平台开发适配OpenHarmony:进度条组件的深度实践
开发语言·前端·flutter·harmonyos·鸿蒙
云和数据.ChenGuang32 分钟前
Uvicorn 是 **Python 生态中用于运行异步 Web 应用的 ASGI 服务器**
服务器·前端·人工智能·python·机器学习