如何使用带边框图像的径向渐变

How to use a radial gradient with a border-image

我正在尝试使用源为径向渐变的边框图像。我看过很多带有图像的示例,但看过 none 径向渐变。

My CodePen

中的完整示例
#main {
  width: 200px;
  border: 8px solid red;
  padding: 10px;
  border-image:
      radial-gradient( farthest-corner, #777 50%, #7770 60%)  /* source */
      28 /                    /* slice */
      8px 8px 8px 8px /    /* width */
      4px 4px 4px 4px       /* outset */
      round;                  /* repeat */
}

我只想用间隔几个像素的小圆圈包围盒子,最好使用仅 CSS 的解决方案。虽然我很高兴听到其他问题

你可以用这样的背景来做:

#main {
  width: 200px;
  padding:10px;
  background: 
   radial-gradient(circle at center, #777 60%, transparent 61%) top left/10px 10px repeat-x,
   radial-gradient(circle at center, #777 60%, transparent 61%) bottom left/10px 10px repeat-x;
}
<div id="main">This element is surrounded by a radial-gradient-based border image!</div>

如果你想要所有的面,你可以这样做:

#main {
  width: 200px;
  padding:13px 10px;
  background: 
   radial-gradient(circle at center, #777 60%, transparent 61%) top left/10px 10px repeat-x,
   radial-gradient(circle at center, #777 60%, transparent 61%) bottom left/10px 10px repeat-x,
   radial-gradient(circle at center, #777 60%, transparent 61%) bottom left/10px 10px repeat-y,
   radial-gradient(circle at center, #777 60%, transparent 61%) bottom right/10px 10px repeat-y;
}
<div id="main">This element is surrounded by a radial-gradient-based border image!</div>