Это может быть достигнуто с помощью небольшой хитрости, оборачивая ваше изображение в контейнер. Свойство border-radius
немного вводит в заблуждение, поэтому вам нужно подумать о четырех сторонах и посмотреть, как можно создать тот же эффект.
Сначала убедитесь, что у вас есть эффект двойной границы.
.image-border {
display: inline-block; /* Fits the wrapper to the size of the image */
overflow: hidden; /* Keeps the image inside the container */
border-radius: 50%;
border-width: 8px;
border-style: solid;
border-color: red red blue blue; /* Define colosr for top, right, bottom, and left sides */
}
.image-border > img {
display: block; /* Prevent baseline alingment (space below image) */
}
<div class="image-border">
<img src="https://via.placeholder.com/175" alt="img=1" />
</div>
Теперь единственная проблема заключается в том, что граница имеет «смещение» на 45 градусов. Вы можете легко исправить это с помощью преобразований:
.image-border {
display: inline-block; /* Fits the wrapper to the size of the image */
overflow: hidden; /* Keeps the image inside the container */
border-radius: 50%;
border-width: 8px;
border-style: solid;
border-color: red red blue blue; /* Define colosr for top, right, bottom, and left sides */
transform: rotate(-45deg); /* Make the borders look aligned to the horizontal axis */
}
.image-border > img {
display: block; /* Prevent baseline alingment (space below image) */
transform: rotate(45deg); /* Cancel the container's transform */
}
<div class="image-border">
<img src="https://via.placeholder.com/175" alt="img=1" />
</div>
Существуют другие методы, такие как градиент, установленный в качестве фонового изображения, с padding
или прозрачной рамкой, чтобы показать его. Это забавный трюк, поэтому я подумал, что вы можете узнать больше из этого!