css实现梯形标签页


html

<nav>click me</nav>

css

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);
}

效果图

如果我们想得到向左侧倾斜或者向右侧倾斜的梯形,只需要将transform-origin设置为bottom left 或者 bottom right即可

css

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;
}

效果图

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM