带有特殊修剪角的CSS按钮[重复]

问题描述 投票:0回答:1

这个问题在这里已有答案:

enter image description here

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

css
1个回答
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>
© www.soinside.com 2019 - 2024. All rights reserved.