Css Triangle边框和boder半径一点

时间:2016-11-17 13:07:08

标签: css border shape

我必须在css中创建这个形状:

enter image description here

但是我无法在css的三角形上进行舍入。 这是我的代码:

.contour {
  padding: 60px 40px 40px 40px;
  margin: 10px;
  width: auto;
  -webkit-border-radius: 11px;
  -moz-border-radius: 11px;
  border-radius: 11px;
  border: solid 3px #FD8906;
  position: relative;
  background-color: #FFF;
}
.contour:after,
.contour:before {
  top: -3px;
  left: 10%;
  border: solid transparent;
  content: " ";
  height: 0;
  width: 0;
  position: absolute;
  pointer-events: none;
}
.contour:after {
  border-color: rgba(255, 255, 255, 0);
  border-top-color: #ffffff;
  border-width: 33px;
  margin-left: -33px;
}
.contour:before {
  border-color: rgba(253, 137, 6, 0);
  border-top-color: #FD8906;
  border-width: 38px;
  margin-left: -38px;
}
<html>
<div class="contour">
</div>

</html>

https://jsfiddle.net/dxjv2jus/

请帮助我

1 个答案:

答案 0 :(得分:1)

您可以通过绘制圆角方框并对其应用旋转来制作它。

html{  background-color:#FFF;}
.contour {
  position: relative;
  overflow: hidden;
  margin:10px;
}
.contour-holder {
  padding:60px 40px 40px 40px;
  width:auto;
  -webkit-border-radius: 11px;
  -moz-border-radius: 11px;
  border-radius: 11px;
  border:solid 3px #FD8906;
  position: relative;
  background-color:#FFF;
}	

.contour:before {
  transform: rotate(-45deg);
  border-radius: 0 0 0 10px;
  left: 10%;
  border:solid 3px #FD8906;
  background: white;
  content: " ";
  height: 40px;
  width: 40px;
  position: absolute;
  pointer-events: none;
  top: -23px;
  z-index: 10;
}
<div class="contour">
  <div class="contour-holder">
  
  </div>
</div>