CSS右箭头

时间:2016-02-19 07:07:45

标签: html css css-shapes

我正在尝试用css创建带有灰色边框的右箭头。但我认为箭头重叠在左边的矩形上。这里需要一些点睛之笔:

.arrow_box {
  position: relative;
  background: #fff;
  border: 2px solid #aaa;
  width: 300px;
  padding: 8px 20px 8px 40px;
}
.arrow_box:after,
.arrow_box:before {
  left: 100%;
  top: 50%;
  border: solid transparent;
  content: " ";
  height: 0;
  width: 0;
  position: absolute;
  pointer-events: none;
}
.arrow_box:after {
  border-color: rgba(255, 255, 255, 0);
  border-left-color: #fff;
  border-width: 17px;
  margin-top: -17px;
}
.arrow_box:before {
  border-color: rgba(170, 170, 170, 0);
  border-left-color: #aaa;
  border-width: 19px;
  margin-top: -19px;
}
<div class="arrow_box"><a href="#">Consumer Customer</a>
</div>

1 个答案:

答案 0 :(得分:1)

您可以在除右侧之外的特定边添加边框:

.arrow_box {
position: relative;
background: #fff;
border-left: 2px solid #aaa;
border-top: 2px solid #aaa;
border-bottom: 2px solid #aaa;
width: 300px;
padding: 8px 20px 8px 40px;
box-sizing: border-box;
}

https://jsfiddle.net/2ca4aucm/1/