如何写出超级好看并且高级的tab切换

因为项目中有这个需求 需要写一个和饿了么或者美团一样的tab切换样式(切换是到店自提还是外卖配送) 废话不多说 直接上图。

送货上门
到店自取

上代码 满满的干活啊

html
<div class="address-tab">
      <div class="tab-list">
          <div class="tab-item left"><span class="text">送货上门</span></div>
          <div class="tab-item right"><span class="text">到店自提</span></div>
      </div>
</div>
css
$borderRadius: 30px;
    .address-tab{
      height: 88px;
      position: relative;
      overflow: hidden;
      border-radius: 16px 16px 0 0;
      &:after,&:before{
        content: '';
        height: 44px;
        position: absolute;
        width: 100%;
        z-index: 1;
      }
      &:before{
        top: 0;
        background: #fff3cc;
      }
      &:after{
        bottom: 0;
        background: #ffffff;
      }
      .tab-list{
        display: block;
        width: 100%;
        height: 100%;
        font-size: 0;
        line-height: 0;
        position: relative;
        z-index: 11;
        margin: 0 -40px;
        padding: 0 40px;
        transform: skewX(10deg);
        &.active {
          transform: skewX(-10deg);
          .tab-item .text {
            transform: skewX(10deg);
          }
          .tab-item.left {
            border-bottom-right-radius: $borderRadius;
            border-top-right-radius: 0;
            background: #fff3cc;
            .text {
              color: rgba(0,0,0,0.5);
              font-weight: normal;
            }
          }
          .tab-item.right {
            border-top-left-radius: $borderRadius;
            background: #fff;
            border-bottom-left-radius: 0;
            .text {
              color: #333;
              font-weight: bold;
            }
          }
        }
      }
      .tab-item{
        width: 50%;
        height: 88px;
        display: inline-block;
        vertical-align: top;
        .text {
          display: block;
          width: 100%;
          height: 100%;
          transform: skewX(-10deg);
          line-height: 88px;
          font-size: 30px;
          text-align: center;
          user-select: none;
        }
        &.left{
          background: #fff;
          color: #333;
          font-weight: 700;
          border-top-right-radius: $borderRadius;
        }
        &.right {
          background: #fff3cc;
          border-bottom-left-radius: $borderRadius;
        }
        &.right .text {
          color: rgba(0,0,0,0.5);
        }
      }
    }
END
有什么问题或者疑问欢迎提出 在线解答 哈哈哈哈.
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。