【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); // 重点
            }
        }
    }
相关推荐
蔗理苦4 小时前
2025-09-05 CSS3——盒子模型
前端·css·css3
二川bro5 小时前
第25节:VR基础与WebXR API入门
前端·3d·vr·threejs
上单带刀不带妹5 小时前
Node.js 的模块化规范是什么?CommonJS 和 ES6 模块有什么区别?
前端·node.js·es6·模块化
缘如风5 小时前
easyui 获取自定义的属性
前端·javascript·easyui
诗书画唱5 小时前
【前端教程】JavaScript 实现图片鼠标悬停切换效果与==和=的区别
开发语言·前端·javascript
光影少年5 小时前
前端上传切片优化以及实现
前端·javascript·掘金·金石计划
喜葵5 小时前
前端安全防护深度实践:从XSS到供应链攻击的全面防御
前端·安全·xss
_r0bin_5 小时前
分片上传-
前端·javascript·状态模式
东北南西5 小时前
手写React状态hook
前端·javascript·react.js