外圆角选项卡
代码
CSS代码:
.tab-x { display: flex; flex-direction: row-reverse; justify-content: flex-end; padding-left: 20px; border-bottom: 1px solid rgba(0,0,0,.1); } .tab-a { --backgroundColor: #fff; background-color: var(--backgroundColor); line-height: 20px; padding: 10px 20px; border-radius: 16px 16px 0 0; filter: drop-shadow(0 -1px 1px rgba(0,0,0,.1)); position: relative; } /* 创建外侧圆弧 */ .tab-a::before, .tab-a::after { content: ''; position: absolute; bottom: 0; width: 16px; height: 16px; } .tab-a::before { background: radial-gradient(circle at 0 0, transparent, transparent 16px, var(--backgroundColor) 17px); right: 100%; } .tab-a::after { background: radial-gradient(circle at 100% 0, transparent, transparent 16px, var(--backgroundColor) 17px); left: 100%; } .tab-a.active { --backgroundColor: teal; color: #fff; z-index: 1; }
HTML代码:
<div class="tab-x"> <a href="javascript:" class="tab-a">选项卡3</a> <a href="javascript:" class="tab-a">选项卡2</a> <a href="javascript:" class="tab-a active">选项卡1</a> </div>
这里外部的圆角使用径向渐变实现。我们也可以使用box-shadow
实现类似的效果,如下:
代码如下:
<div class="quar-radius"></div>
.quar-radius { width: 96px; height: 96px; border-radius: 0 0 50% 0; clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); box-shadow: 0 0 0 100px teal; }