用纯CSS伪元素写一个倒梯形

首先看看需求,tab栏上的一个active样式

 

 

//找到active时的选择器
.active::before {
  content: '';
  width: 100%;
  height: 6px;
  background-color: green;
  display: inline-block;
  position: absolute;
  left: 0;
  top: -1px;
  transform: perspective(125px) rotateX(135deg);
}

可以根据自己的样式调整角度及高度

posted @ 2020-07-01 17:15  Jennyishere  阅读(1308)  评论(0)    收藏  举报