CSS3繪製平行四邊形程式碼例項

admin發表於2017-05-26

分享一段程式碼例項,它利用css3實現了平行四邊形效果。

程式碼例項如下:

[HTML] 純文字檢視 複製程式碼執行程式碼
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>螞蟻部落</title>
<style type="text/css">
.button {
  position: relative;
  display: inline-block;
  padding: .5em 1em;
  border: 0; margin: .5em;
  background: transparent;
  color: white;
  text-transform: uppercase;
  text-decoration: none;
  font: bold 200%/1 sans-serif;
}
.button::before {
  content: ''; /* To generate the box */
  position: absolute;
  top: 0; 
  right: 0; 
  bottom: 0; 
  left: 0;
  z-index: -1;
  background: #58a;
  transform: skew(45deg);
}
</style>
</head>
<body>
<button class="button">
  <div>螞蟻部落</div>
</button>
</body>
</html>

相關文章