1.animation 判断动画结束,结束后执行另一事件;2.用css3写竖条纹背景

1.用css3的animation完成一个动画,并监听动画结束后才执行另一个事的实现方法:

动画结束时有一个webkitAnimationEnd事件,只要监听这个事件就可以

2.用css3写带透明色的竖条纹背景:

 background-image: linear-gradient(90deg, #00a7ed 50%,transparent 50%);   //让背景的渐变带有90度的倾斜,也就是变成竖条纹

  background-size: 4px 100%;  //每一部分都有自己的宽度和高度

效果图:

 

<div class="workingPlan">
    <div class="divHeader">{{ workingPlan.name }}</div>
    <div class="cutLine"></div>
    <div class="divComponent">
      <div
        class="workingPlanItem"
        v-for="(item, index) in workingPlan.data"
        :key="index"
      >
        <span class="name">{{ item.name }}</span>
        <div class="progress">
          <div class="container">
            <span
              class="process"
              :style="{ width: getProgress(item).progress }"
            ></span>
          </div>
          <span v-if="showProgress">{{ getProgress(item).progress }}</span>
        </div>
      </div>
    </div>
  </div>
export default {
  name: "workingPlan",
  components: {},
  methods: {
    getProgress(data) {
      return {
        progress: (data.value / data.total).toFixed(2) * 100 + "%",
      };
    },
  },
  mounted() {
    const end = document.querySelector(".process"),
      that = this;
    end.addEventListener("webkitAnimationEnd", function () {
      that.showProgress = true;
    });
  },
  data() {
    return {
      showProgress: false,
      workingPlan: {
        name: "工作计划",
        data: [
          {
            name: "工作计划1",
            value: 4,
            total: 20,
          },
          {
            name: "工作计划2",
            value: 10,
            total: 20,
          },
        ],
      },
    };
  },
};
.workingPlan {
  border-radius: 16px;
  height: 25%;
  width: 100%;
  background-color: rgb(249, 253, 255);
}
.divHeader {
  font-size: 17px;
  padding: 10px;
  font-weight: bold;
  text-align: center;
}
.cutLine {
  width: 100%;
  height: 5px;
  background-image: linear-gradient(to right, #3633d8, #44bbf7);
}
.divComponent {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  width: 99%;
  height: calc(100% - 50px);
  padding: 10px 15px 5px 15px;
  /*border: 1px solid red;*/
}
.workingPlanItem {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  width: 100%;
  height: 25%;
  text-align: left;
}
.name {
  font-size: 15px;
}
.progress {
  height: 45%;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.container {
  width: 80%;
  height: 30%;
  background: #dbdfe2;
}
.process {
  display: block;
  height: 100%;
  position: relative;
  background-image: linear-gradient(90deg, #3633d8 50%, transparent 50%);
  background-size: 4px 100%;
  animation: change 5s linear 0s 1;
}
@keyframes change {
  0% {
    width: 0px;
  }
  100% {
    width: "getProgress(item).progress";
  }
}
.process::after {
  content: "";
  width: 2px;
  height: 200%;
  background: #3633d8;
  position: absolute;
  top: -40%;
  right: -1px;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值