CSS篇之圆角梯形

附上一篇文章:梯形tab按钮-基于clip-path path函数实现 - JSRUN.NET

他这个区别在于,收尾两侧都是直角的,如图

下面这个是圆角:

思路:

代码如下:

<template>
  <div class="wrap">
    <div class="tabs">
      <div v-for="index in 3" :key="index" class="box">
        <div class="tab" :class="{ active: activeIndex == index }" @click="onTabClick(index)">
          {
  { '标签' + index }}
        </div>
      </div>
    </div>
    <div class="content-wrap"></div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      activeIndex: -1,
      tabList: [
        { id: 1, label: '数据真短' },
        { id: 21, label: '数据报告' },
        { id: 31, label: '数据展示' }
      ]
    };
  },
  methods: {
    onTabClick(val) {
      this.activeIndex = val;
    }
  }
};
</script>

<style lang="scss">
.wrap {
  background-color: #eee;
  width: 620px;
  margin: 0 auto;
  padding: 10px;
  box-sizing: border-box;
}

.tabs {
  display: flex;
  width: 100%;
  overflow: hidden;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(#cdd9fe, #e2e9fd);
  .box {
    width: 200px;
    height: 50px;
  }
}

.tab {
  width: 100px;
  height: 50px;
  margin: 0 auto;
  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 50,0 C 25,0 25,50 0,50 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;
}
</style>

最后:附上一个CSS实现的另一种方法

实现梯形圆角tab - 掘金

相关推荐

  1. CSS3设置圆角

    2023-12-17 20:38:04       52 阅读
  2. re:从0开始的CSS旅 12. 轮廓、阴影、圆角

    2023-12-17 20:38:04       50 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-17 20:38:04       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-17 20:38:04       106 阅读
  3. 在Django里面运行非项目文件

    2023-12-17 20:38:04       87 阅读
  4. Python语言-面向对象

    2023-12-17 20:38:04       96 阅读

热门阅读

  1. 70.爬楼梯

    2023-12-17 20:38:04       61 阅读
  2. 基于Hadoop的智慧社区大数仓库系统设计与开发

    2023-12-17 20:38:04       55 阅读
  3. 串的处理。

    2023-12-17 20:38:04       51 阅读
  4. 基于SpringBoot的和微信小程序养老院管理系统

    2023-12-17 20:38:04       69 阅读
  5. 刚clone下来的项目如何上传到新的仓库

    2023-12-17 20:38:04       50 阅读
  6. 矩阵的相似标准型2

    2023-12-17 20:38:04       40 阅读
  7. android实战之Lifecycle感知组件生命周期

    2023-12-17 20:38:04       57 阅读
  8. RDD编程

    RDD编程

    2023-12-17 20:38:04      50 阅读
  9. 数据资产的类型有哪些?

    2023-12-17 20:38:04       58 阅读
  10. springboot 学习网站

    2023-12-17 20:38:04       64 阅读
  11. NX二次开发(NXOpenC++) - 切换制图模块方法

    2023-12-17 20:38:04       95 阅读