Как создать разноцветную рамку? - PullRequest
0 голосов
/ 11 июня 2018

Как создать неровную и разноцветную границу, подобную изображению ниже?

enter image description here

Ответы [ 2 ]

0 голосов
/ 11 июня 2018

Вы можете использовать псевдоэлементы ::before и ::after для достижения этого:

.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>

Обратите внимание, что вы можете сделать больше границ видимыми, если вам нужно.

Надеюсь, это поможет.

0 голосов
/ 11 июня 2018

Вы можете использовать градиент, чтобы создать это:

.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>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...