How to create multi-color border with CSS?

Hamed mayahian picture Hamed mayahian · Aug 9, 2016 · Viewed 35.6k times · Source

How to create multi-color border like image below?

enter image description here

Answer

Theodore K. picture Theodore K. · Aug 9, 2016

You can do it without pseudo-elements, just with border-image: linear-gradient

.fancy-border {
  width: 150px;
  height: 150px;
  text-align:center;
  border-top: 5px solid;
  border-image:   linear-gradient(to right, grey 25%, yellow 25%, yellow 50%,red 50%, red 75%, teal 75%) 5;
}
<div class="fancy-border">
  my content
</div>