效果如下
<template>
<div class="coupon-box">
<div class="l">
<div class="p1">
<slot name="left"></slot>
</div>
<div class="p2">
<div class="top"></div>
<div class="bottom"></div>
</div>
</div>
<div class="r">
<div class="p1">
<div class="top"></div>
<div class="bottom"></div>
</div>
<div class="p2">
<slot name="right"></slot>
</div>
</div>
</div>
</template>
<script>
export default {
};
</script>
<style lang="less" scoped>
.coupon-box {
@themeColor: #4286F5;
@themeColorDisabled: #ADAFB4;
@roundWidth: 10px;
width: 92%;
height: 115px;
display: flex;
.l {
width: 104px;
height: 100%;
display: flex;
.p1, .p2 {
background-color: @themeColor;
}
.p1 {
width: 94px;
height: 100%;
border-radius: 4px 0 0 4px;
box-shadow: 0px 0px 12px 0px rgba(0,0,0,0.08);
}
.p2 {
width: calc(@roundWidth + 1px);
height: calc(100% - @roundWidth * 2);
margin-top: auto;
margin-bottom: auto;
position: relative;
margin-left: -1px;
}
.top, .bottom {
width: calc(@roundWidth + 1px);
height: 60px;
background-size: 10px 60px;
background-repeat: no-repeat;
position: absolute;
right: 0;
}
.top {
background: radial-gradient(circle at right 0px, transparent 10px, @themeColor 10px);
background-position: right top;
top: -@roundWidth;
}
.bottom {
background: radial-gradient(circle at right bottom, transparent 10px, @themeColor 10px);
background-position: right bottom;
bottom: -@roundWidth;
}
}
.r {
width: calc(100% - 104px);
height: 100%;
position: relative;
display: flex;
.p1, .p2 {
background-color: #fff;
}
.p1 {
width: calc(@roundWidth + 1px);
height: calc(100% - @roundWidth * 2);
margin-top: auto;
margin-bottom: auto;
position: relative;
}
.p2 {
width: calc(100% - @roundWidth);
height: 100%;
border-radius: 0 4px 4px 0;
box-shadow: 0px 0px 12px 0px rgba(0,0,0,0.08);
}
.top, .bottom {
width: calc(@roundWidth + 2px);
height: 60px;
background-size: 10px 60px;
background-repeat: no-repeat;
position: absolute;
left: 0;
}
.top {
background: radial-gradient(circle at left 0px, transparent 10px, #fff 10px);
background-position: left top;
top: -@roundWidth;
}
.bottom {
background: radial-gradient(circle at left bottom, transparent 10px, #fff 10px);
background-position: left bottom;
bottom: -@roundWidth;
}
}
}
</style>
最大难点在这里
既需要内凹又要透明,券整体还要有box-shadow
并且手机上div间还会可能有莫名的连接缝隙
试过伪类、纯radial-gradient + linear-gradient都不理想
看了好几个已有实现都不满足,比如
https://codepen.io/Ariex/pen/...
https://codepen.io/mudontire/...
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。