我尝试使用CSS为图像(图A)添加三种实心颜色的外围渐变边框(图B),但是迄今为止尝试的方法都没能成功。这些图像将具有border-radius:50%以使其成为圆形,并且外部边框需要随着图像缩放。我希望能够仅使用CSS类快速将其应用于任何图像。
我已经尝试过SVG掩模、边框图片和常规覆盖,但是都无法完成所需的任务。这个代码示例是我最接近的尝试,但是我需要在图像和边框之间留出空白。
.img-circle{
border-radius: 50%;
}
.border {
margin: 25px 0;
/*padding: 1em;*/
border: 12px solid transparent;
background-size: 100% 100%, 60% 60%, 40% 40%, 25% 50%;
background-repeat: no-repeat;
background-image: linear-gradient(white, white),
linear-gradient(30deg, teal 36%, teal 30%),
linear-gradient(120deg, gold 36%, gold 30%),
linear-gradient(210deg, blue 36%, blue 30%);
background-position: center center, left top, right top, left bottom, right bottom;
background-origin: content-box, border-box, border-box, border-box;
background-clip: content-box, border-box, border-box, border-box;
}
<img src="https://placeimg.com/280/280/any" class="border img-circle">
你对我应该如何处理这个问题有什么想法?