vue实战范例——箭头步骤条/导航(含css 斜切skew的妙用)

简介: vue实战范例——箭头步骤条/导航(含css 斜切skew的妙用)

<template>
  <div>
    <div class="arrowsBox">
      <div class="arrowsItem" v-for="(item, index) in list" :key="index">
        <div
          class="arrows-up arrows"
          :class="{
            arrows_active: item.status === 'active',
            arrows_done: item.status === 'done',
            arrows_todo: item.status === 'todo',
          }"
        ></div>
        <div
          class="arrows-down arrows"
          :class="{
            arrows_active: item.status === 'active',
            arrows_done: item.status === 'done',
            arrows_todo: item.status === 'todo',
          }"
        ></div>
        <div
          class="arrows-label"
          :class="{
            arrows_label_active: item.status === 'active',
            arrows_label_done: item.status === 'done',
            arrows_label_todo: item.status === 'todo',
          }"
        >
          {{ item.label }}
        </div>
      </div>
    </div>

    <button v-if="unFinish" @click="next" class="btn">下一步</button>
  </div>
</template>
<script>
export default {
  data() {
    return {
      unFinish: true,
      list: [
        {
          label: "1-规则说明",
          prop: "1",
          status: "done",
        },
        {
          label: "2-参与活动",
          prop: "2",
          status: "done",
        },
        {
          label: "3-参与抽奖",
          prop: "3",
          status: "active",
        },
        {
          label: "4-奖品发放",
          prop: "4",
          status: "todo",
        },
        {
          label: "5-查看结果",
          prop: "5",
          status: "todo",
        },
      ],
    };
  },
  methods: {
    next() {
      for (let item of this.list) {
        if (item.status === "active") {
          item.status = "done";
        }

        if (item.status === "todo") {
          item.status = "active";
          if (this.list[this.list.length - 1].status === "active") {
            this.unFinish = false;
          }
          break;
        }
      }
    },
  },
};
</script>
<style scoped>
.arrowsBox {
  display: flex;
  justify-content: center;
  height: 40px;
  margin: 20px;
  font-weight: bold;
}
.arrowsItem {
  position: relative;
  height: 100%;
  width: 140px;
  margin-right: 10px;
}
.arrows-up {
  transform: skewX(30deg);
}
.arrows-down {
  transform: skewX(-30deg);
}
.arrows {
  height: 50%;

  background: gray;
}

.arrows-label {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 0;
  right: 0;
  bottom: 0;
  text-align: center;
}
.arrows_done {
  background: #edf9ff;
}
.arrows_active {
  background: #009fe9;
}
.arrows_todo {
  background: #ebedf0;
}

.arrows_label_done {
  color: #009fe9;
}
.arrows_label_active {
  color: #fff;
}
.arrows_label_todo {
  color: #929393;
}
.btn {
  background: #009fe9;
  color: #fff;
  border: none;
  padding: 6px;
  width: 100px;
  border-radius: 4px;
  margin: auto;
  display: block;
}
</style>

css 斜切skew的妙用

目录
相关文章
|
2天前
|
移动开发 前端开发 HTML5
CSS 【实战】 “四合院”布局
CSS 【实战】 “四合院”布局
5 0
CSS 【实战】 “四合院”布局
|
3天前
|
前端开发
css 巧用 ::after 和 ::before 实现竖排分类导航
css 巧用 ::after 和 ::before 实现竖排分类导航
11 1
|
5天前
|
JavaScript 前端开发 容器
vue组件封装——固定宽高比的容器(2种方法:纯CSS实现 + JS实现)
vue组件封装——固定宽高比的容器(2种方法:纯CSS实现 + JS实现)
9 2
|
5天前
|
JavaScript 前端开发
vue 模拟随机变速的动态打字特效【支持多行文本】(含css实现闪烁光标,js动态改变setInterval定时器的时间间隔)
vue 模拟随机变速的动态打字特效【支持多行文本】(含css实现闪烁光标,js动态改变setInterval定时器的时间间隔)
10 1
|
3天前
|
前端开发
css实战——清除列表中最后一个元素的下边距
css实战——清除列表中最后一个元素的下边距
8 0
|
5天前
|
前端开发 JavaScript
vue 自定义气泡弹窗 $pop (内含css晃动动画shake制作)
vue 自定义气泡弹窗 $pop (内含css晃动动画shake制作)
11 0
|
4天前
|
前端开发 JavaScript
文本,wangEditor5展示HTML无样式,wangEditor5如何看源码,Ctrl + U看CSS文件,代码高亮,Prism.js可以实现,解决方法,参考网页源代码的写法
文本,wangEditor5展示HTML无样式,wangEditor5如何看源码,Ctrl + U看CSS文件,代码高亮,Prism.js可以实现,解决方法,参考网页源代码的写法
|
11天前
|
安全 JavaScript
旋转木马轮播图 html+css+js
旋转木马轮播图 html+css+js
|
11天前
|
移动开发 前端开发 JavaScript
HTML5+CSS3+JavaScript网页实战
HTML5+CSS3+JavaScript网页实战