可以参考下这个
"https://jsrun.net/JHFKp" (https://link.segmentfault.com/?enc=xCfV1EMPjs5D1cYzvZl9vA%3D%3D.JNASEr4JwJzC9EnXf8uxygVoap9N4cBqTJw5OmgFVhg%3D)
梯形tab按钮-基于clip-path path函数实现
.wrap {
background-color: #eee;
width: 375px;
margin: 0 auto;
padding: 10px;
}
.tabs {
display: flex;
width: 100%;
overflow: hidden;
border-radius: 8px 8px 0 0;
background: linear-gradient(#cdd9fe, #e2e9fd);
}
.tab {
flex: 0 0 50.1%;
height: 50px;
cursor: pointer;
position: relative;
text-align: center;
line-height: 50px;
}
.tab.active {
background-color: #fff;
color: #4185ef;
}
.tab.active:before {
content: '';
position: absolute;
top: 0;
left: -50px;
height: 100%;
width: 50px;
z-index: 2;
background-color: #fff;
clip-path: path('M 0,50 C 25,50 25,0 50,0 L 50, 50 Z');
}
.tab.active:after {
content: '';
position: absolute;
top: 0;
right: -50px;
height: 100%;
width: 50px;
z-index: 2;
background-color: #fff;
clip-path: path('M 0,0 C 25,0 25,50 50,50 L 0, 50 Z');
}
.content-wrap {
min-height: 200px;
background-color: #fff;
}
// pass unocss options
window.__unocss = {
rules: [
// custom rules...
],
presets: [
// custom presets...
],
// ...
}
function initData() {
return {
activeIndex: 1,
onTabClick(index) {
this.activeIndex = index
}
}
}