CSS overlapping transparent arrow elements

Is this possible with CSS? I tried using before / after pseudo-elements, and although I can make something work for solid colors, I am having problems with the ability to do this with transparency.

http://puu.sh/ctOL6/875fb5db8f.png

Any suggestions?

+4
source share
2 answers

If you do not need black borders around each element (as can be seen from the published image), you can still create the necessary shapes in the borderfollowing way:

.timeline-unit:before, .timeline-unit:after {
    top: 0;
    border: solid transparent;
    border-width: 1.65em;
    height: 0;
    width: 0;
    position: absolute;
    pointer-events: none;
}

.timeline-unit:after {
    content: " ";
    left: 100%;
    border-left-color: rgba(51, 51, 51, 0.8);
}

.timeline-unit {
    position: relative;
    display: inline-block;
    background: rgba(51,51,51,.8);
    padding: 1em;
    line-height: 1.25em;
    color: #FFF;
}

.timeline-unit:before { content: none; }

.timeline-unit + .timeline-unit:before {
    content: " ";
    border-color: rgba(51, 51, 51, 0.8);
    border-left-color: transparent;
    border-right: 0;
    right: 100%;
}

.timeline-unit + .timeline-unit {
    margin-left: 2em;
}

/**************  D E M O  **************/

body {
  background: red;
    
  -webkit-animation: bgcolor 4s linear 0s infinite alternate;
     -moz-animation: bgcolor 4s linear 0s infinite alternate;
       -o-animation: bgcolor 4s linear 0s infinite alternate;
          animation: bgcolor 4s linear 0s infinite alternate;
}

@-webkit-keyframes bgcolor { from { background: red; } to { background: green; }  }
   @-moz-keyframes bgcolor { from { background: red; } to { background: green; }  }
     @-o-keyframes bgcolor { from { background: red; } to { background: green; }  }
        @keyframes bgcolor { from { background: red; } to { background: green; }  }
<div class="timeline-unit"> Timeline 1 </div>
<div class="timeline-unit"> Timeline 2 </div>
<div class="timeline-unit"> Timeline 3 </div>
Run code

However, if you need to add a border for each element, there are two options:

+4

, .

li {
  display: inline-block;
  background: none repeat scroll 0 0 #e6e6e6;
  position: relative;
  list-style: none outside none;
  margin-right: 5px;
  line-height: 18px;
  padding: 12px 17px 10px 30px;
}
li:first-child {
  padding-left: 12px;
}
li:first-child:before {
  border: 0 none;
}
li:before {
  content:"";
  position: absolute;
  top: 0;
  height: 0;
  border-left: 20px solid white;
  border-bottom: 20px inset transparent;
  border-top: 20px inset transparent;
  width: 0;
  left: 0;
}
li:after {
  content:"";
  height: 0;
  border-left: 20px solid #e6e6e6;
  right: -20px;
  border-top: 20px inset transparent;
  border-bottom: 20px inset transparent;
  z-index: 2;
  width: 0;
  position: absolute;
  top: 0;
}
<ul>
  <li>daTA1</li>
  <li>daTA2</li>
  <li>daTA3</li>
  <li>daTA4</li>
</ul>
  

enter image description here

+2

All Articles