带有特殊修剪角的CSS按钮

时间:2018-02-28 19:08:41

标签: css

enter image description here

这是一张图片。但我想用CSS做同样的事情。用CSS做普通按钮很方便,但不是这个按钮。是否可以在CSS中执行相同的角落?

1 个答案:

答案 0 :(得分:1)



.container {
  background-color: black;
  height:200px; width: 100%;
  padding:50px;
}



.custom-button {
  width: 150px;
  height: 40px;
  background-color: #29aa4c;
  position: relative;
  color: white;
  font-weight: bold;
  text-align:center;
  line-height:40px;
  font-family: sans-serif;
  font-size:18px;
}

.custom-button:before {
  content: '';
  position: absolute;
  top:0;
  left:0;
  width: 0;
  height: 0;
  border-top: 20px solid black;
  border-right: 20px solid transparent;
}

.custom-button:after {
  content: '';
  position: absolute;
  bottom:0;
  right:0;
  width: 0;
  height: 0;
  border-bottom: 20px solid black;
  border-left: 20px solid transparent;
}

<div class="container">
  <div class="custom-button">
    Sign In
  </div>

</div>
&#13;
&#13;
&#13;