css3實現的矩形切角效果

antzone發表於2017-03-02

分享一段程式碼例項,它實現了矩形四邊切角效果。

程式碼例項如下:

[HTML] 純文字檢視 複製程式碼
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>螞蟻部落</title>
<style type="text/css">
.notching{
  position: absolute;
  top:50%;
  left: 50%;
  transform:translate(-50%,-50%);
  width: 160px;
  padding: 60px 20px;
  text-align: center;
  color: white;
  font-size: 200%;
}
.notching{
  background:
   linear-gradient(135deg, transparent 15px, deeppink 0) top left,
   linear-gradient(-135deg, transparent 15px, deeppink 0) top right,
   linear-gradient(-45deg, transparent 15px, deeppink 0) bottom right,
   linear-gradient(45deg, transparent 15px, deeppink 0) bottom left;
 background-size: 50% 50%;
 background-repeat: no-repeat;
}        
</style>
</head>
<body>
<div class="notching"></div>
</body>
</html>

相關文章