css梯形程式碼例項

antzone發表於2018-05-20

下面是使用css繪製一個梯形的程式碼例項,需要的朋友可以做一下參考。

程式碼例項如下:

[HTML] 純文字檢視 複製程式碼執行程式碼
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>螞蟻部落</title>
<style type="text/css">
.box {
  width: 200px;
  height: 200px;
  padding: 10px;
  margin: 10px 20px;
}
.tab {
  position: relative;
  padding: .5em 1em .35em;
  color: white;
}
.tab::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: -1;
  background: #58a;
  transform: perspective(.5em) rotateX(5deg);
  transform-origin: bottom;
}
</style>
</head>
<body>
<div class="box tab">梯形</div>
</body>
</html>

相關文章