线性渐变可以用作图像边框的颜色吗

Can Linear Gradient be used as the color of the border of an image

我们可以给图片的边框做线性渐变吗?? 像这样:

img {
    border: 10px solid linear-gradient(to right, red , blue);
}

如果没有我们还能做些什么来实现相同的风格。

最简单的是填充和背景:

img {
  background: linear-gradient(to right, red, blue);
  padding: 10px;
}
<img src="https://dummyimage.com/200">

对于 border-image,查看 and this tool to help you sort it out https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Background_and_Borders/Border-image_generator