Triangles via borders in CSS

by jshacker

HTML

<div class="border"></div>
<div class="only-triangle"></div>

CSS

div {
  margin: 50px;
  width: 50px;
  height: 50px;
  border-color: red green blue yellow;
  border-style: solid;
  border-width: 50px;
  
  animation-duration: 3s;
  animation-fill-mode: forwards;
  animation-iteration-count: infinite;
  animation-delay: 1s;
}
.border {
  animation-name: example;
}
.only-triangle {
  animation-name: onlyTriangle;
}

@keyframes example {
  100% {
    border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.2) blue rgba(0, 0, 0, 0.3);
    height: 0;
    width: 0;
  }
}

@keyframes onlyTriangle {
  100% {
    border-color: transparent transparent blue transparent;
    height: 0;
    width: 0;
    border-top-width: 0;
    outline: none;
  }
}