CSS - 从-到淡化渐变边框

CSS - fading gradient border from-to

我想使我的整个 div 部分具有淡化边框。这是我的代码:

.usermanagement {
  -webkit-border-image: -webkit-gradient(
      linear,
      left top,
      left bottom,
      from(#fff),
      to(#afd4ec),
      color-stop(0.2, #afd4ec)
    )
    0 0 0 0 repeat repeat;
}

效果正是我想要的,但仅限于顶部:

然后全部变成浅蓝色,然后像这样结束:

没有这种褪色效果。我想为该部分的底端制作与顶部相同的效果。怎么可能?

您可以像下面这样尝试。确保正确设置不同的值。

.box {
  height:50px; /* this need to be a multiple of 10 for the effect to work */
  border-top:   10px solid;
  border-bottom:10px solid;
  background:#f2f2f2;
  border-image:repeating-linear-gradient(#fff 0,red 10px) 10;
}
<div class="box"></div>

你也可以用多个背景来做:

.box {
  height:50px;
  border-top:10px solid transparent;
  border-bottom:10px solid transparent;
  background:
   linear-gradient(#fff ,red ) top,
   linear-gradient(#fff ,red ) bottom, /* use (red, #fff) here for the opposite effect */
   #f2f2f2;
  background-size:100% 10px;
  background-origin:border-box;
  background-repeat:no-repeat;
}
<div class="box"></div>