0

How to create a border that is uneven and multicolored similar to the below image ?

enter image description here

Flying Gambit
  • 1,238
  • 1
  • 15
  • 32

2 Answers2

2

You can use pseudo-elements ::before and ::after to achieve that:

.box {
  position: relative;
  background: #66d;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 6px solid #ddd;
}

.box::before, .box::after {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  margin: -6px; /* width of the border */
  border-radius: 50%;
  border: 6px solid transparent;
  content: '';
}

.box::before {
  border-top-color: #bbb;
  transform: rotate(45deg);   /* 45deg to start right on top */
}

.box::after {
  border-right-color: #bbb;   /* You can color the borders you want… */
  /* transform: rotate(0deg); /* … and adjust the rotation if needed */
}
<div class="box"></div>

Note that you could make more borders visible if you need.

Hope it helps.

Takit Isy
  • 9,688
  • 3
  • 23
  • 47
1

You can use gradient to create this:

.box {
  width:100px;
  height:100px;
  border-radius:50%;
  background:
   radial-gradient(circle at center, blue 60%,transparent 60.1%),
   linear-gradient(to right,#fff 50%,transparent 0),
   linear-gradient(50deg,#fff 50%,transparent 0),
   red;
}
<div class="box">

</div>
Temani Afif
  • 245,468
  • 26
  • 309
  • 415