chrome弧形标签页实现思路收录
1. 直线圆角,通过单个伪元素的border-radius产生弧形
<template> <div class="tab-list"> <div v-for="tab in tabs" :key="tab.id" class="tab-item" :class="activeTab === tab.id ? 'active' : ''" @click="onTab(tab.id)" > <div>{{ tab.label }}</div> </div> </div> </template> <script> export default { data() { return { tabs: [ { id: 0, label: '' }, { id: 1, label: '我的信息' }, { id: 2, label: '我信' }, { id: 3, label: '我的信' }, { id: 4, label: '我的信息流' }, { id: 5, label: '' }, ], activeTab: 2, }; }, methods: { onTab(id) { this.activeTab = id; }, }, }; </script> <style lang="scss"> // scss $tab-height: 52px; $active-color: #ffffff; $default-color: #e2e8f8; $primary-color: blue; .tab-list { display: flex; position: relative; z-index: 2; border-radius: 12px 12px 0 0; background-color: $default-color; overflow: hidden; padding: 0 80px; .tab-item:first-child, .tab-item:last-child { flex: none; } .tab-item:last-child::after{ display: none; } .tab-item { flex: auto; height: $tab-height; display: flex; justify-content: center; align-items: center; font-size: 14px; color: $primary-color; font-weight: 600; position: relative; } .tab-item.active { opacity: 1; background: #fff; border-radius: 12px 12px 0 0; box-shadow: 12px 43px 0 $active-color, -12px 43px 0 0 $active-color; } .tab-item.active::before { content: ''; position: absolute; bottom: 0; width: 12px; height: $tab-height; border-bottom-right-radius: 12px; background: $default-color; left: -12px; z-index: 1; } .tab-item.active::after { content: ''; position: absolute; bottom: 0; width: 12px; height: $tab-height; right: 6px; background: $default-color; border-bottom-left-radius: 12px; z-index: 1; right: -12px; } } </style>
详细可参考 实现tabs圆角及反圆角效果
2. 斜线圆角,通过两个相邻伪元素的border-radius和skew配合产生两个弧形
<template> <div class="tab-list"> <div v-for="tab in tabs" :key="tab.id" class="tab-item" :class="activeTab === tab.id ? 'active' : ''" @click="onTab(tab.id)" > <div>{{ tab.label }}</div> </div> </div> </template> <script> export default { data() { return { tabs: [ { id: 0, label: '' }, { id: 1, label: '我的信息' }, { id: 2, label: '我信' }, { id: 3, label: '我的信' }, { id: 4, label: '我的信息流' }, { id: 5, label: '' }, ], activeTab: 1, }; }, methods: { onTab(id) { this.activeTab = id; }, }, }; </script> <style lang="scss"> // scss $tab-height: 52px; $active-color: #ffffff; $default-color: #e2e8f8; $primary-color: blue; .tab-list { display: flex; position: relative; z-index: 2; border-radius: 12px 12px 0 0; background-color: $default-color; overflow: hidden; padding: 0 80px; .tab-item:first-child, .tab-item:last-child { flex: none; } .tab-item:last-child::after{ display: none; } .tab-item { flex: auto; height: $tab-height; display: flex; justify-content: center; align-items: center; font-size: 14px; color: $primary-color; font-weight: 600; position: relative; } .tab-item.active { opacity: 1; background: #fff; border-radius: 12px 12px 0 0; box-shadow: 24px 40px 0 $active-color, -24px 40px 0 0 $active-color; } .tab-item::before { content: ''; position: absolute; bottom: 0; width: 12px; height: $tab-height; left: 6px; border-bottom-left-radius: 12px; background: $default-color; transform: skewX(15deg); } .tab-item.active::before { left: -6px; border-top-left-radius: 12px; background: $active-color; transform: skewX(-15deg); } .tab-item::after { content: ''; position: absolute; bottom: 0; width: 12px; height: $tab-height; right: 6px; background: $default-color; border-bottom-right-radius: 12px; transform: skewX(-15deg); z-index: 1; } .tab-item.active::after { right: -6px; border-top-right-radius: 12px; background: $active-color; transform: skewX(15deg); } } </style>
详细参考此文 实现tabs圆角及反圆角效果(PLUS)
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
2015-12-12 改变placeholder颜色
2015-12-12 express快速搭建web server