css實現梯形標籤頁

htmlcss

<nav>click me</nav>

csshtml

nav{
  position: relative;
  display: inline-block;
  padding: 15px;
  font-size: 24px;
  color: white;
  margin: 50px;
}
nav::before{
  content: '';
  position: absolute;
  top:0;left:0;right:0;bottom:0;
  z-index: -1;
  background: #58a;
  transform: perspective(.5em) rotateX(5deg);
}

效果圖spa

若是咱們想獲得向左側傾斜或者向右側傾斜的梯形,只須要將transform-origin設置爲bottom left 或者 bottom right便可3d

csscode

nav{
  position: relative;
  display: inline-block;
  padding: 50px 40px 15px 15px;
  font-size: 24px;
  color: white;
  margin: 50px;
}
nav::before{
  content: '';
  position: absolute;
  top:0;left:0;right:0;bottom:0;
  z-index: -1;
  background: #58a;
  transform: perspective(.5em) rotateX(5deg);
  transform-origin: bottom left;
}

效果圖orm

相關文章
相關標籤/搜索