如何在CSS HTML中使用连续箭头框

时间:2018-01-12 03:04:48

标签: html css html5

任何想法如何做这样的事情?enter image description here

我知道他们只是对css进行修改的盒子,但我是css的新手,所以任何一种帮助都会有用。谢谢

即时通过以下操作来完成此操作。但是盒子之间有一个空间。我想实现覆盖每个盒子之间空间的箭头

.box {
  display: block;
  width: 100%;
  margin: 0 auto;
  padding: 50px 20px;
  text-align: center;
  overflow: hidden;
}

.box-item {
  display: block;
  position: relative;
  float: left;
  width: calc(100% / 3 - 7px);
  height: 40px;
  line-height: 40px;
  margin-right: 10px;
  padding: 0 10px;
  background-color: #3a7cca;
  border-radius: 4px;
  color: #ffffff;
}
.box-item:before {
  content: "";
  position: absolute;
  right: -9px;
  height: 0;
  width: 0;
  border-top: 20px solid transparent;
  border-bottom: 20px solid transparent;
  border-left: 10px solid #3a7cca;
  border-radius: 4px;
}
.box-item:after {
  content: "";
  position: absolute;
  left: -1px;
  height: 0;
  width: 0;
  border-top: 20px solid transparent;
  border-bottom: 20px solid transparent;
  border-left: 10px solid #fff;
  border-radius: 4px;
}
.box-item:first-child:after {
  display: none;
}
.box-item:last-child {
  margin-right: 0;
}
.box-item:last-child:before {
  display: none;
}

1 个答案:

答案 0 :(得分:0)

尝试将display: flexflex-direction: row-reverse用于父块。因此,每个下一个.box-item将被放置在""之前,您可以通过更改margin-right来调整项目之间的空间。



.box {
  display: flex;
  flex-direction: row-reverse;
  padding: 50px 20px;
}

.box-item {
  align-items: center;
  background: #3a7cca;
  border-radius: 4px;
  color: white;
  display: flex;
  flex-grow: 1;
  height: 40px;
  justify-content: center;
  margin-right: 2px;
  position: relative;
}

.box-item:before,
.box-item:after {
  border-color: transparent;
  border-style: solid;
  border-width: 20px 0 20px 10px;
  border-radius: 4px;
  content: "";
  height: 0;
  position: absolute;
  top: 0;
  width: 0;
}

.box-item:before {
  left: -1px;
  border-left-color: white;
}

.box-item:after {
  right: -9px;
  border-left-color: #3a7cca;
}

.box-item:first-child {
  margin-right: 0;
}

.box-item:last-child:before,
.box-item:first-child:after {
  display: none;
}

<div class="box">
  <div class="box-item">3</div>
  <div class="box-item">2</div>
  <div class="box-item">1</div>
</div>
&#13;
&#13;
&#13;