简体   繁体   English

CSS:连续显示三角形

[英]CSS: show triangles in a row

My HTML markup with CSS can be seen in this link . 我可以在此链接中看到我的CSS HTML标记。 Here, you can see that the last triangle with the box is looking fine. 在这里,您可以看到带框的最后一个三角形看起来很好。 Actually, here I have made 3 triangles with the boxes. 实际上,这里我用盒子制作了3个三角形。 In every box-1-wrap, box-2-wrap and in box-3-wrap there is one box and a triangle is made. 在每个box-1-wrap, box-2-wrapbox-3-wrap有一个盒子和一个三角形。

Now, I want the triangle of the first div to be shown. 现在,我希望显示第一个div的三角形。 They are in a line. 他们排成一列。 So here I want the first row to show just above the second box and the second triangle should be shown above the 3rd box. 所以在这里我希望第一行显示在第二个框的上方,第二个三角形应显示在第三个框的上方。

Can someone here kindly help me out here? 有人可以在这里帮助我吗?

Here's how the output file should look like: 以下是输出文件的外观:

在此输入图像描述

All you have to do is position each consecutive box under the previous one. 您所要做的就是将每个连续的框放在前一个框下面

Add this to your CSS: 将其添加到您的CSS:

.box-1-wrap{
    position:relative;
    z-index:3;
}
.box-2-wrap{
    position:relative;
    z-index:2;
}
.box-3-wrap{
    position:relative;
    z-index:1;
}

Here is a demonstration: http://jsfiddle.net/PrDyq/11/ 这是一个演示: http//jsfiddle.net/PrDyq/11/

.box-1-wrap, .box-2-wrap, .box-3-wrap {
  display: inline-block;
}
.light-blue-box {
  padding: 20px 40px;
  height: 0;
  background: #2D98F0;
  display:inline-block;
}
.arrow-first {
width: 0;
height: 0;
border-left: 20px solid #2D98F0;
border-top: 20px solid #2B90E3;
border-bottom: 20px solid #2B90E3;
display: inline-block;
margin: 0 0 0 -5px;
}
.light-blue-box-2 {
  padding: 20px 40px;
  height: 0;
  background: #2B90E3;
  display:inline-block;
  margin:0 0 0 -4px;
  z-index:999;
}
.arrow-second {
  width: 0;
  height: 0;
  border-left: 20px solid #2B90E3;
border-top: 20px solid #2879BB;
border-bottom: 20px solid #2879BB;
  display: inline-block;
  margin: 0 0 0 -5px
}
.light-blue-box-3 {
  padding: 20px 40px;
  height: 0;
  background: #2879BB;
  display:inline-block;
  margin:0 0 0 -4px;
  z-index:999;
}
.arrow-third {
  width: 0;
  height: 0;
  border-left: 20px solid #2879BB;
  border-top: 20px solid transparent;
  border-bottom: 20px solid transparent;
  display: inline-block;
  margin: 0 0 0 -5px
}

Add this code and check 添加此代码并检查

A more general solution with less css and less html: http://jsfiddle.net/Z5pTR/1/ 一个更通用的解决方案,更少的CSS和更少的HTML: http//jsfiddle.net/Z5pTR/1/

Supporting IE <9 would require manually annotating the first and last elements rather than using first-child ; 支持IE <9将需要手动注释第一个和最后一个元素而不是使用first-child ; adding one placeholder in the end rather than using :after and finally not using css3's hsla . 最后添加一个占位符而不是使用:after并且最后不使用css3的hsla

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM